/// <summary> /// Initializes a new instance of the <see cref="PeriodList" /> class. /// </summary> /// <param name="value">The value.</param> public PeriodList(string value) : this() { var serializer = new PeriodListSerializer( ); CopyFrom(serializer.Deserialize(new StringReader(value)) as ICopyable); }
public PeriodList(string value) : this() { PeriodListSerializer serializer = new PeriodListSerializer(); StringReader reader = new StringReader(value); CopyFrom(serializer.Deserialize(reader) as ICopyable); reader.Dispose(); }
/// <summary> /// Returns a serializer that can be used to serialize and object /// of type <paramref name="objectType"/>. /// <note> /// TODO: Add support for caching. /// </note> /// </summary> /// <param name="objectType">The type of object to be serialized.</param> /// <param name="ctx">The serialization context.</param> public virtual ISerializer Build(Type objectType, SerializationContext ctx) { if (objectType != null) { ISerializer s; if (typeof(Attachment).IsAssignableFrom(objectType)) { s = new AttachmentSerializer(); } else if (typeof(Attendee).IsAssignableFrom(objectType)) { s = new AttendeeSerializer(); } else if (typeof(IDateTime).IsAssignableFrom(objectType)) { s = new DateTimeSerializer(); } else if (typeof(FreeBusyEntry).IsAssignableFrom(objectType)) { s = new FreeBusyEntrySerializer(); } else if (typeof(GeographicLocation).IsAssignableFrom(objectType)) { s = new GeographicLocationSerializer(); } else if (typeof(Organizer).IsAssignableFrom(objectType)) { s = new OrganizerSerializer(); } else if (typeof(Period).IsAssignableFrom(objectType)) { s = new PeriodSerializer(); } else if (typeof(PeriodList).IsAssignableFrom(objectType)) { s = new PeriodListSerializer(); } else if (typeof(RecurrencePattern).IsAssignableFrom(objectType)) { s = new RecurrencePatternSerializer(); } else if (typeof(RequestStatus).IsAssignableFrom(objectType)) { s = new RequestStatusSerializer(); } else if (typeof(StatusCode).IsAssignableFrom(objectType)) { s = new StatusCodeSerializer(); } else if (typeof(Trigger).IsAssignableFrom(objectType)) { s = new TriggerSerializer(); } else if (typeof(UtcOffset).IsAssignableFrom(objectType)) { s = new UtcOffsetSerializer(); } else if (typeof(WeekDay).IsAssignableFrom(objectType)) { s = new WeekDaySerializer(); } // Default to a string serializer, which simply calls // ToString() on the value to serialize it. else { s = new StringSerializer(); } // Set the serialization context s.SerializationContext = ctx; return(s); } return(null); }
/// <summary> /// Returns a <see cref="System.String" /> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String" /> that represents this instance. /// </returns> public override string ToString( ) { var serializer = new PeriodListSerializer( ); return(serializer.SerializeToString(this)); }
public PeriodList(string value) : this() { PeriodListSerializer serializer = new PeriodListSerializer(); CopyFrom(serializer.Deserialize(new StringReader(value)) as ICopyable); }
public override string ToString() { PeriodListSerializer serializer = new PeriodListSerializer(); return serializer.SerializeToString(this); }