protected void SerializeValue(ISerializerFactory sf, ICalendarProperty prop, Type valueType, object v, StringBuilder result) { // Get a serializer to serialize the property's value. // If we can't serialize the property's value, the next step is worthless anyway. IStringSerializer valueSerializer = sf.Build(valueType, SerializationContext) as IStringSerializer; if (valueSerializer != null) { // Iterate through each value to be serialized, // and give it a property (with parameters). // FIXME: this isn't always the way this is accomplished. // Multiple values can often be serialized within the // same property. How should we fix this? // NOTE: // We Serialize the property's value first, as during // serialization it may modify our parameters. // FIXME: the "parameter modification" operation should // be separated from serialization. Perhaps something // like PreSerialize(), etc. string value = valueSerializer.SerializeToString(v); // Get the list of parameters we'll be serializing ICalendarParameterCollection parameterList = prop.Parameters; if (v is ICalendarDataType) { parameterList = ((ICalendarDataType)v).Parameters; } StringBuilder sb = new StringBuilder(prop.Name); if (parameterList.Any()) { // Get a serializer for parameters IStringSerializer parameterSerializer = sf.Build(typeof(ICalendarParameter), SerializationContext) as IStringSerializer; if (parameterSerializer != null) { // Serialize each parameter List <string> parameters = new List <string>(); foreach (ICalendarParameter param in parameterList) { parameters.Add(parameterSerializer.SerializeToString(param)); } // Separate parameters with semicolons sb.Append(";"); sb.Append(string.Join(";", parameters.ToArray())); } } sb.Append(":"); sb.Append(value); result.Append(TextUtil.WrapLines(sb.ToString())); } }
void Initialize() { _Parameters = new CalendarParameterList(); _Proxy = new CalendarParameterCollectionProxy(_Parameters); _ServiceProvider = new ServiceProvider(); }
private void Initialize() { _Values = new List <object>(); _Parameters = new CalendarParameterList(this, true); ValueChanged += new EventHandler <ValueChangedEventArgs <object> >(CalendarProperty_ValueChanged); }
private void Initialize() { _Values = new List<object>(); _Parameters = new CalendarParameterList(this, true); }
private void Initialize() { _parameters = new CalendarParameterList(); _proxy = new CalendarParameterCollectionProxy(_parameters); _serviceProvider = new ServiceProvider(); }
private void Initialize() { _Values = new List <object>(); _Parameters = new CalendarParameterList(this, true); }
private void Initialize() { _values = new List <object>(128); _parameters = new CalendarParameterList(this, true); ValueChanged += CalendarProperty_ValueChanged; }
public override string SerializeToString(object obj) { ICalendarProperty prop = obj as ICalendarProperty; if (prop != null && prop.Values != null && prop.Values.Any()) { // Don't serialize the property if the value is null // Push this object on the serialization context. SerializationContext.Push(prop); IDataTypeMapper mapper = GetService <IDataTypeMapper>(); Type serializedType = mapper.GetPropertyMapping(prop); // Get a serializer factory that we can use to serialize // the property and parameter values ISerializerFactory sf = GetService <ISerializerFactory>(); StringBuilder result = new StringBuilder(); foreach (object v in prop.Values) { // Only serialize the value to a string if it // is non-null. if (v != null) { // Get a serializer to serialize the property's value. // If we can't serialize the property's value, the next step is worthless anyway. IStringSerializer valueSerializer = sf.Build(v.GetType(), SerializationContext) as IStringSerializer; if (valueSerializer != null) { // Iterate through each value to be serialized, // and give it a property (with parameters). // FIXME: this isn't always the way this is accomplished. // Multiple values can often be serialized within the // same property. How should we fix this? // NOTE: // We Serialize the property's value first, as during // serialization it may modify our parameters. // FIXME: the "parameter modification" operation should // be separated from serialization. Perhaps something // like PreSerialize(), etc. string value = valueSerializer.SerializeToString(v); // Get the list of parameters we'll be serializing ICalendarParameterCollection parameterList = prop.Parameters; if (v is ICalendarDataType) { parameterList = ((ICalendarDataType)v).Parameters; } StringBuilder sb = new StringBuilder(prop.Name); if (parameterList.Any()) { // Get a serializer for parameters IStringSerializer parameterSerializer = sf.Build(typeof(ICalendarParameter), SerializationContext) as IStringSerializer; if (parameterSerializer != null) { // Serialize each parameter List <string> parameters = new List <string>(); foreach (ICalendarParameter param in parameterList) { parameters.Add(parameterSerializer.SerializeToString(param)); } // Separate parameters with semicolons sb.Append(";"); sb.Append(string.Join(";", parameters.ToArray())); } } sb.Append(":"); sb.Append(value); result.Append(TextUtil.WrapLines(sb.ToString())); } } } // Pop the object off the serialization context. SerializationContext.Pop(); return(result.ToString()); } return(null); }
private void Initialize() { _Values = new List<object>(); _Parameters = new CalendarParameterList(this, true); ValueChanged += new EventHandler<ValueChangedEventArgs<object>>(CalendarProperty_ValueChanged); }