コード例 #1
0
 /// <summary>
 /// Loads each iCalendar into our iCalendarCollection.
 /// </summary>
 private void Schedule_Load(object sender, EventArgs e)
 {
     _Calendars.Add(iCalendar.LoadFromFile(@"Calendars\USHolidays.ics"));
     _Calendars.Add(iCalendar.LoadFromFile(@"Calendars\lotr.ics"));
     _Calendars.Add(iCalendar.LoadFromFile(@"Calendars\To-do.ics"));
     _Calendars.Add(iCalendar.LoadFromFile(@"Calendars\Barça 2006 - 2007.ics"));
 }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: MaitreDede/dday-ical
 /// <summary>
 /// Loads and parses the selected calendars.
 /// </summary>
 protected void LoadSelectedCalendars()
 {
     _Calendars = new iCalendarCollection();
     foreach (ListItem li in CalendarList.Items)
     {
         // Make sure the item is selected
         if (li.Selected)
         {
             // Load the calendar from the file system
             _Calendars.Add(iCalendar.LoadFromFile(Path.Combine(_CalendarAbsPath, li.Text + @".ics")));
         }
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: MaitreDede/dday-ical
        public void EVALUATION1()
        {
            iCalendarCollection calendars = new iCalendarCollection();
            calendars.Add(iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE21.ics"));
            calendars.Add(iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE22.ics"));

            Date_Time startDate = new Date_Time(1996, 1, 1, tzid, calendars[0]);
            Date_Time endDate = new Date_Time(1998, 4, 1, tzid, calendars[0]);
            
            List<Date_Time> DateTimes = new List<Date_Time>(new Date_Time[]
            {
                new Date_Time(1997, 9, 2, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 9, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 16, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 23, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 30, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 11, 4, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 11, 11, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 11, 18, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 11, 25, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 1, 6, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 1, 13, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 1, 20, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 1, 27, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 3, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 10, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 17, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 24, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 31, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 10, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 11, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 12, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 13, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 14, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 15, 9, 0, 0, tzid, calendars[0]),                
            });
            
            List<Event> occurrences = new List<Event>(calendars.GetRecurrencesForRange<Event>(startDate, endDate));
            foreach (Event evt in occurrences)
                Assert.IsTrue(DateTimes.Contains(evt.Start), "Event occurred on " + evt.Start + "; it should not have");
            foreach(Date_Time dt in DateTimes)
            {
                bool isFound = false;
                foreach (Event evt in occurrences)
                {
                    if (evt.Start.Equals(dt))
                    {
                        isFound = true;
                        break;
                    }
                }
                Assert.IsTrue(isFound, "Event should occur on " + dt);
            }
                    

            Assert.IsTrue(occurrences.Count == DateTimes.Count, "There should be exactly " + DateTimes.Count + " occurrences; there were " + occurrences.Count);
        }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: xxjeng/nuxleus
 /// <summary>
 /// Loads and parses the selected calendars.
 /// </summary>
 protected void LoadSelectedCalendars()
 {
     _Calendars = new iCalendarCollection();
     foreach (ListItem li in CalendarList.Items)
     {
         // Make sure the item is selected
         if (li.Selected)
         {
             // Load the calendar from the file system
             _Calendars.Add(iCalendar.LoadFromFile(Path.Combine(_CalendarAbsPath, li.Text + @".ics")));                
         }
     }
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: xxjeng/nuxleus
        static void Main(string[] args)
        {
            // Create an empty list of iCalendars
            iCalendarCollection iCalendars = new iCalendarCollection();

            // First, load the example iCalendar file normally
            iCalendars.Add(iCalendar.LoadFromFile(@"Example3.ics"));
            
            // Next, load the example iCalendar file into our CustomICalendar object,
            // so we can show the difference between loading it normally and loading
            // it into a custom object.
            iCalendars.Add(iCalendar.LoadFromFile<CustomICalendar>(@"Example3.ics"));

            // Since our CustomICalendar objects has its ComponentBaseTypeAttribute set
            // to our CustomComponentBase class, all of our objects are created with it.
            //
            // Hence, each of our events will not be loaded as Event objects, because we
            // instructed our CustomComponentBase class to create a CustomEvent class
            // whenever a VEVENT object was encountered.

            foreach (iCalendar iCal in iCalendars)
            {
                Console.WriteLine("iCalendar is of type: " + iCal.GetType().Name);

                int i = 1;

                //
                // Iterate through each unique component in the iCalendar
                //
                foreach (ComponentBase component in iCal.UniqueComponents)
                {
                    // Display the component's type                    
                    Console.WriteLine(i + ": Component is a " + component.GetType().Name + ", which is a subclass of " + component.GetType().BaseType.Name);
                    
                    if (component is CustomEvent)
                    {
                        // The component was loaded as a CustomEvent                        
                        CustomEvent evt = (CustomEvent)component;
      
                        // So, let's set some additional information
                        evt.AdditionalInformation = @"
More information to set about this event...
Note that this information will not be saved
when the iCalendar is serialized.  We'll deal
with this in the next example.
";

                        // Let's show its summary also...
                        Console.WriteLine("\tEvent summary: " + evt.Summary);
                    }
                    else
                    {
                        // The component is not a CustomEvent, because
                        // the iCalendar was loaded normally.
                        Console.WriteLine("\tComponent is not a CustomEvent.");
                    }

                    i++;
                }

                Console.WriteLine(Environment.NewLine);
            }
        }
コード例 #6
0
ファイル: iCalParser.cs プロジェクト: logikonline/DDay.iCal
	public IICalendarCollection  icalendar(
		ISerializationContext ctx
	) //throws RecognitionException, TokenStreamException
{
		IICalendarCollection iCalendars = new iCalendarCollection();
		
		
		
			SerializationUtil.OnDeserializing(iCalendars);
		
			IICalendar iCal = null;
			ISerializationSettings settings = ctx.GetService(typeof(ISerializationSettings)) as ISerializationSettings;
		
		{    // ( ... )*
			for (;;)
			{
				if ((LA(1)==CRLF||LA(1)==BEGIN))
				{
					{    // ( ... )*
						for (;;)
						{
							if ((LA(1)==CRLF))
							{
								match(CRLF);
							}
							else
							{
								goto _loop4_breakloop;
							}
							
						}
_loop4_breakloop:						;
					}    // ( ... )*
					match(BEGIN);
					match(COLON);
					match(VCALENDAR);
					{    // ( ... )*
						for (;;)
						{
							if ((LA(1)==CRLF))
							{
								match(CRLF);
							}
							else
							{
								goto _loop6_breakloop;
							}
							
						}
_loop6_breakloop:						;
					}    // ( ... )*
								
								ISerializationProcessor<IICalendar> processor = ctx.GetService(typeof(ISerializationProcessor<IICalendar>)) as ISerializationProcessor<IICalendar>;
								
								// Do some pre-processing on the calendar:
								if (processor != null)
									processor.PreDeserialization(iCal);
							
								iCal = (IICalendar)SerializationUtil.GetUninitializedObject(settings.iCalendarType);			
								SerializationUtil.OnDeserializing(iCal);
								
								// Push the iCalendar onto the serialization context stack
								ctx.Push(iCal);
							
					icalbody(ctx, iCal);
					match(END);
					match(COLON);
					match(VCALENDAR);
					{    // ( ... )*
						for (;;)
						{
							if ((LA(1)==CRLF) && (LA(2)==EOF||LA(2)==CRLF||LA(2)==BEGIN) && (tokenSet_0_.member(LA(3))))
							{
								match(CRLF);
							}
							else
							{
								goto _loop8_breakloop;
							}
							
						}
_loop8_breakloop:						;
					}    // ( ... )*
					
								// Do some final processing on the calendar:
								if (processor != null)
									processor.PostDeserialization(iCal);
							
								// Notify that the iCalendar has been loaded
								iCal.OnLoaded();
								iCalendars.Add(iCal);
								
								SerializationUtil.OnDeserialized(iCal);
								
								// Pop the iCalendar off the serialization context stack
								ctx.Pop();
							
				}
				else
				{
					goto _loop9_breakloop;
				}
				
			}
_loop9_breakloop:			;
		}    // ( ... )*
		
				SerializationUtil.OnDeserialized(iCalendars);
			
		return iCalendars;
	}
コード例 #7
0
        static void Main(string[] args)
        {
            // Create an empty list of iCalendars
            iCalendarCollection iCalendars = new iCalendarCollection();

            // First, load the example iCalendar file normally
            iCalendars.Add(iCalendar.LoadFromFile(@"Example3.ics"));

            // Next, load the example iCalendar file into our CustomICalendar object,
            // so we can show the difference between loading it normally and loading
            // it into a custom object.
            iCalendars.Add(iCalendar.LoadFromFile <CustomICalendar>(@"Example3.ics"));

            // Since our CustomICalendar objects has its ComponentBaseTypeAttribute set
            // to our CustomComponentBase class, all of our objects are created with it.
            //
            // Hence, each of our events will not be loaded as Event objects, because we
            // instructed our CustomComponentBase class to create a CustomEvent class
            // whenever a VEVENT object was encountered.

            foreach (iCalendar iCal in iCalendars)
            {
                Console.WriteLine("iCalendar is of type: " + iCal.GetType().Name);

                int i = 1;

                //
                // Iterate through each unique component in the iCalendar
                //
                foreach (ComponentBase component in iCal.UniqueComponents)
                {
                    // Display the component's type
                    Console.WriteLine(i + ": Component is a " + component.GetType().Name + ", which is a subclass of " + component.GetType().BaseType.Name);

                    if (component is CustomEvent)
                    {
                        // The component was loaded as a CustomEvent
                        CustomEvent evt = (CustomEvent)component;

                        // So, let's set some additional information
                        evt.AdditionalInformation = @"
More information to set about this event...
Note that this information will not be saved
when the iCalendar is serialized.  We'll deal
with this in the next example.
";

                        // Let's show its summary also...
                        Console.WriteLine("\tEvent summary: " + evt.Summary);
                    }
                    else
                    {
                        // The component is not a CustomEvent, because
                        // the iCalendar was loaded normally.
                        Console.WriteLine("\tComponent is not a CustomEvent.");
                    }

                    i++;
                }

                Console.WriteLine(Environment.NewLine);
            }
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: MaitreDede/dday-ical
        public void EVALUATION1()
        {
            iCalendarCollection calendars = new iCalendarCollection();

            calendars.Add(iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE21.ics"));
            calendars.Add(iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE22.ics"));

            Date_Time startDate = new Date_Time(1996, 1, 1, tzid, calendars[0]);
            Date_Time endDate   = new Date_Time(1998, 4, 1, tzid, calendars[0]);

            List <Date_Time> DateTimes = new List <Date_Time>(new Date_Time[]
            {
                new Date_Time(1997, 9, 2, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 9, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 16, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 23, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 30, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 11, 4, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 11, 11, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 11, 18, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 11, 25, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 1, 6, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 1, 13, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 1, 20, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 1, 27, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 3, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 10, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 17, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 24, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1998, 3, 31, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 10, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 11, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 12, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 13, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 14, 9, 0, 0, tzid, calendars[0]),
                new Date_Time(1997, 9, 15, 9, 0, 0, tzid, calendars[0]),
            });

            List <Event> occurrences = new List <Event>(calendars.GetRecurrencesForRange <Event>(startDate, endDate));

            foreach (Event evt in occurrences)
            {
                Assert.IsTrue(DateTimes.Contains(evt.Start), "Event occurred on " + evt.Start + "; it should not have");
            }
            foreach (Date_Time dt in DateTimes)
            {
                bool isFound = false;
                foreach (Event evt in occurrences)
                {
                    if (evt.Start.Equals(dt))
                    {
                        isFound = true;
                        break;
                    }
                }
                Assert.IsTrue(isFound, "Event should occur on " + dt);
            }


            Assert.IsTrue(occurrences.Count == DateTimes.Count, "There should be exactly " + DateTimes.Count + " occurrences; there were " + occurrences.Count);
        }