Back to Devexpress

TextProperty Class

corelibraries-devexpress-dot-xtrascheduler-dot-icalendar-dot-components-c2474e21.md

latest5.8 KB
Original Source

TextProperty Class

Enables you to add a new property to the iCalendar component.

Namespace : DevExpress.XtraScheduler.iCalendar.Components

Assembly : DevExpress.XtraScheduler.v25.2.Core.Desktop.dll

NuGet Package : DevExpress.Scheduler.CoreDesktop

Declaration

csharp
public class TextProperty :
    StringPropertyBase,
    ICalendarNamedObject
vb
Public Class TextProperty
    Inherits StringPropertyBase
    Implements ICalendarNamedObject

Remarks

By default, the iCalendarExporter class implements only basic properties of the iCalendar component. To include other properties, such as ‘ATTENDEE’, ‘CONTACT’ or properties with arbitrary names, create an instance of the TextProperty class, corresponding to that property and add it to the collection accessible via the iCalendarComponentBase.CustomProperties.

The following code handles the AppointmentExporter.AppointmentExporting event of the iCalendarExporter. It uses the iCalendarComponentBase.CustomProperties property of the current VEvent object, accessible via the iCalendarAppointmentExportingEventArgs.VEvent property of the event arguments, to add addresses of the attendees to the exported object. So, the exported object is no longer an appointment, but a meeting request with attendees.

csharp
using DevExpress.XtraScheduler.iCalendar;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.iCalendar.Components;
        void ExportAppointments(Stream stream) {
            if (stream == null)
                return;
            iCalendarExporter exporter = new iCalendarExporter(schedulerStorage1);
            exporter.AppointmentExporting += 
                new AppointmentExportingEventHandler(exporter_AppointmentExporting);
            exporter.Export(stream);
        }
        void exporter_AppointmentExporting(object sender, AppointmentExportingEventArgs e) {
            string s = Convert.ToString(e.Appointment.CustomFields[RecipientsDataColumn]);
            string[] attendees = s.Split(';');

            iCalendarAppointmentExportingEventArgs args = e as iCalendarAppointmentExportingEventArgs;
            AddEventAttendees(args.VEvent, attendees);
        }
        private void AddEventAttendees(VEvent ev, string[] addresses) {
            int count = addresses.Length;
            for (int i = 0; i < count; i++)
                AddEventAttendee(ev, addresses[i]);
        }
        private void AddEventAttendee(VEvent ev, string address) {
            TextProperty p = new TextProperty("ATTENDEE", 
                String.Format("mailto:{0}", address));
            p.AddParameter("CN", address);
            p.AddParameter("RSVP", "TRUE");
            ev.CustomProperties.Add(p);
        }
vb
Imports DevExpress.XtraScheduler.iCalendar
Imports DevExpress.XtraScheduler
Imports DevExpress.XtraScheduler.iCalendar.Components
        Private Sub ExportAppointments(ByVal stream As Stream)
            If stream Is Nothing Then
                Return
            End If
            Dim exporter As New iCalendarExporter(schedulerStorage1)
            AddHandler exporter.AppointmentExporting, AddressOf exporter_AppointmentExporting
            exporter.Export(stream)
        End Sub
        Private Sub exporter_AppointmentExporting(ByVal sender As Object, ByVal e As AppointmentExportingEventArgs)
            Dim s As String = Convert.ToString(e.Appointment.CustomFields(RecipientsDataColumn))
            Dim attendees() As String = s.Split(";"c)

            Dim args As iCalendarAppointmentExportingEventArgs = TryCast(e, iCalendarAppointmentExportingEventArgs)
            AddEventAttendees(args.VEvent, attendees)
        End Sub
        Private Sub AddEventAttendees(ByVal ev As VEvent, ByVal addresses() As String)
            Dim count As Integer = addresses.Length
            For i As Integer = 0 To count - 1
                AddEventAttendee(ev, addresses(i))
            Next i
        End Sub
        Private Sub AddEventAttendee(ByVal ev As VEvent, ByVal address As String)
            Dim p As New TextProperty("ATTENDEE", String.Format("mailto:{0}", address))
            p.AddParameter("CN", address)
            p.AddParameter("RSVP", "TRUE")
            ev.CustomProperties.Add(p)
        End Sub

Inheritance

Object DevExpress.XtraScheduler.iCalendar.Components.iCalendarObject DevExpress.XtraScheduler.iCalendar.Components.iCalendarBodyItem DevExpress.XtraScheduler.iCalendar.Components.iCalendarPropertyBase DevExpress.XtraScheduler.iCalendar.Components.StringPropertyBase TextProperty

See Also

TextProperty Members

DevExpress.XtraScheduler.iCalendar.Components Namespace