Пример #1
0
        private bool Parse(ICalInboundContext inboundContext)
        {
            bool result = false;

            if (inboundContext.Reader.ReadNextComponent() && inboundContext.Reader.ComponentId == ComponentId.VCalendar)
            {
                this.vCalendar = new VCalendar(inboundContext);
                if (this.vCalendar.Parse(inboundContext.Reader) && !inboundContext.Reader.ReadNextComponent())
                {
                    result = true;
                }
            }
            return(result);
        }
Пример #2
0
        internal static IEnumerable <Item> InternalICalToItems(Stream iCalStream, string charsetName, InboundAddressCache addressCache, uint?maxBodyLength, bool hasExceptionPromotion, Func <Item> getItem, IList <LocalizedString> errorStream, out string calendarName)
        {
            Util.ThrowOnNullArgument(iCalStream, "iCalStream");
            Util.ThrowOnNullArgument(addressCache, "addressCache");
            Util.ThrowOnNullArgument(errorStream, "errorStream");
            bool flag                           = false;
            LocalizedException ex               = null;
            Charset            charset          = Charset.GetCharset(charsetName ?? "utf-8");
            CalendarDocument   calendarDocument = new CalendarDocument();
            IEnumerable <Item> result;

            using (CalendarReader calendarReader = new CalendarReader(new StreamWrapper(iCalStream, false), charset.Name, CalendarComplianceMode.Loose))
            {
                ICalInboundContext calInboundContext = new ICalInboundContext(charset, errorStream, addressCache, addressCache.Options, calendarReader, maxBodyLength, hasExceptionPromotion);
                try
                {
                    flag = (calendarDocument.Parse(calInboundContext) && calendarDocument.vCalendar.Validate());
                }
                catch (InvalidCalendarDataException ex2)
                {
                    ex = ex2;
                }
                calendarName = calInboundContext.CalendarName;
                if (!flag)
                {
                    if (ex != null)
                    {
                        ExTraceGlobals.ICalTracer.TraceError <string>((long)calendarDocument.GetHashCode(), "CalendarDocument::InternalICalToItems. Found exception: '{0}'.", ex.Message);
                        errorStream.Add(ex.LocalizedString);
                    }
                    else if (errorStream.Count != 0)
                    {
                        ExTraceGlobals.ICalTracer.TraceError <int>((long)calendarDocument.GetHashCode(), "CalendarDocument::InternalICalToItems. {0} error found.", errorStream.Count);
                        errorStream.Add(ServerStrings.InvalidICalElement("VCALENDAR"));
                    }
                    result = Array <CalendarItemBase> .Empty;
                }
                else
                {
                    result = calendarDocument.vCalendar.Promote(getItem);
                }
            }
            return(result);
        }