예제 #1
0
 public void WriteTo(Stream destination)
 {
     this.stream.Position = 0L;
     using (CalendarReader calendarReader = new CalendarReader(new SuppressCloseStream(this.stream), this.originalCharset.Name, CalendarComplianceMode.Loose))
     {
         using (CalendarWriter calendarWriter = new CalendarWriter(new SuppressCloseStream(destination), this.targetCharset.Name))
         {
             calendarWriter.SetLooseMode();
             this.properties.Write(calendarReader, calendarWriter);
         }
     }
 }
예제 #2
0
        internal static ReadOnlyCollection <AttachmentLink> InternalItemsToICal(string calendarName, IList <Item> items, ReadOnlyCollection <AttachmentLink> existingAttachmentLinks, OutboundAddressCache addressCache, bool suppressExceptionAndAttachmentDemotion, Stream stream, List <LocalizedString> errorStream, string charsetName, OutboundConversionOptions outboundConversionOptions)
        {
            Util.ThrowOnNullArgument(items, "items");
            if (!suppressExceptionAndAttachmentDemotion && items.Count != 1)
            {
                throw new ArgumentException("Non suppressExceptionAndAttachmentDemotion mode should have one and only one item to demote");
            }
            Charset          charset          = Charset.GetCharset(charsetName);
            CalendarDocument calendarDocument = new CalendarDocument();

            using (CalendarWriter calendarWriter = new CalendarWriter(new StreamWrapper(stream, false), charset.Name))
            {
                ICalOutboundContext outboundContext = new ICalOutboundContext(charset, errorStream, addressCache, outboundConversionOptions, calendarWriter, calendarName, existingAttachmentLinks, suppressExceptionAndAttachmentDemotion);
                calendarDocument.Demote(outboundContext, items);
            }
            return(existingAttachmentLinks);
        }
예제 #3
0
            internal void Write(CalendarReader reader, CalendarWriter writer)
            {
                int num = 0;

                while (reader.ReadNextComponent())
                {
                    while (num-- >= reader.Depth)
                    {
                        writer.EndComponent();
                    }
                    writer.StartComponent(reader.ComponentName);
                    this.WriteProperties(reader, writer);
                    num = reader.Depth;
                }
                while (num-- > 0)
                {
                    writer.EndComponent();
                }
            }
예제 #4
0
 internal static void Demote(CalendarWriter calendarWriter, TimeSpan minutes, string description, string recipientAddress)
 {
     calendarWriter.StartComponent(ComponentId.VAlarm);
     calendarWriter.WriteProperty(PropertyId.Description, description);
     calendarWriter.StartProperty(PropertyId.Trigger);
     calendarWriter.WriteParameter("RELATED", "START");
     calendarWriter.WritePropertyValue(minutes);
     if (recipientAddress == null)
     {
         calendarWriter.WriteProperty(PropertyId.Action, "DISPLAY");
     }
     else
     {
         calendarWriter.WriteProperty(PropertyId.Action, "EMAIL");
         calendarWriter.WriteProperty(PropertyId.Summary, "Reminder");
         calendarWriter.WriteProperty(PropertyId.Attendee, recipientAddress);
     }
     calendarWriter.EndComponent();
 }
예제 #5
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Email();
            //ExStart: WriteMultipleEventsToICS
            IcsSaveOptions saveOptions = new IcsSaveOptions();

            saveOptions.Action = AppointmentAction.Create;
            using (CalendarWriter writer = new CalendarWriter(dataDir + "WriteMultipleEventsToICS_out.ics", saveOptions))
            {
                for (int i = 0; i < 10; i++)
                {
                    Appointment app = new Appointment(string.Empty, DateTime.Now, DateTime.Now, "*****@*****.**", "*****@*****.**");
                    app.Description = "Test body " + i;
                    app.Summary     = "Test summary:" + i;
                    writer.Write(app);
                }
            }
            //ExEnd: WriteMultipleEventsToICS
        }
예제 #6
0
            private void WriteProperties(CalendarReader reader, CalendarWriter writer)
            {
                CalendarPropertyReader propertyReader = reader.PropertyReader;

                while (propertyReader.ReadNextProperty())
                {
                    PropertyId propertyId = propertyReader.PropertyId;
                    bool       flag;
                    if (ComponentId.VEvent == reader.ComponentId && this.dirty.TryGetValue(propertyId, out flag) && flag)
                    {
                        object obj = this[propertyId];
                        if (obj != null)
                        {
                            this.WriteProperty(writer, propertyId, obj);
                        }
                    }
                    else
                    {
                        writer.WriteProperty(propertyReader);
                    }
                }
            }
예제 #7
0
            private void WriteProperty(CalendarWriter writer, PropertyId id, object value)
            {
                BodyData bodyData = value as BodyData;

                if (bodyData != null)
                {
                    using (Stream readStream = bodyData.GetReadStream())
                    {
                        using (StreamReader streamReader = new StreamReader(readStream, bodyData.Encoding))
                        {
                            string value2 = streamReader.ReadToEnd();
                            writer.WriteProperty(id, value2);
                        }
                        return;
                    }
                }
                string value3 = value as string;

                if (!string.IsNullOrEmpty(value3))
                {
                    writer.WriteProperty(id, value3);
                }
            }
예제 #8
0
 internal ICalOutboundContext(Charset charset, IList <LocalizedString> errorStream, OutboundAddressCache addressCache, OutboundConversionOptions options, CalendarWriter calendarWriter, string calendarName, ReadOnlyCollection <AttachmentLink> attachmentLinks, bool suppressExceptionAndAttachmentDemotion) : base(charset, errorStream, addressCache)
 {
     Util.ThrowOnNullArgument(options, "options");
     Util.ThrowOnNullOrEmptyArgument(options.ImceaEncapsulationDomain, "options.ImceaEncapsulationDomain");
     Util.ThrowOnNullArgument(calendarWriter, "calendarWriter");
     this.Options         = options;
     this.Writer          = calendarWriter;
     this.CalendarName    = calendarName;
     this.AttachmentLinks = attachmentLinks;
     this.SuppressExceptionAndAttachmentDemotion = suppressExceptionAndAttachmentDemotion;
 }