public static ComponentProperty <TransparencyValues.TransparencyValue> Deserialize( this IValue <TransparencyValues.TransparencyValue> property, string value, List <PropertyParameter> parameters) { ((ComponentProperty <TransparencyValues.TransparencyValue>)property).PropertyParameters = parameters; property.Value = TransparencyValues.ContertValue(value); return((ComponentProperty <TransparencyValues.TransparencyValue>)property); }
/// <summary> /// Call this the method when u want the representation in string of the /// Components properties classes /// </summary> /// <param name="property"></param> /// <returns></returns> public static string StringRepresentation <T>(this ComponentProperty <T> property) { var strBuilder = new StringBuilder(property.Name); foreach (var proParam in property.PropertyParameters) { strBuilder.Append(";"); strBuilder.Append(proParam.Name + "=" + proParam.Value); } strBuilder.Append(":"); if (property is IValue <string> ) { strBuilder.Append(((IValue <string>)property).Value); } else if (property is IValue <IList <string> > ) { var flag = false; foreach (var cat in ((IValue <IList <string> >)property).Value) { if (flag) { strBuilder.Append(','); } strBuilder.Append(cat); flag = true; } } else if (property is IValue <ClassificationValues.ClassificationValue> ) { strBuilder.Append( ClassificationValues.ToString(((IValue <ClassificationValues.ClassificationValue>)property).Value)); } else if (property is IValue <int> ) { strBuilder.Append(((IValue <int>)property).Value); } else if (property is IValue <StatusValues.Values> ) { strBuilder.Append(StatusValues.ToString(((IValue <StatusValues.Values>)property).Value)); } else if (property is IValue <TransparencyValues.TransparencyValue> ) { strBuilder.Append( TransparencyValues.ToString(((IValue <TransparencyValues.TransparencyValue>)property).Value)); } else if (property is IValue <DateTime> ) { var propValue = ((IValue <DateTime>)property).Value; if ( property.PropertyParameters.Count( propertyParameter => propertyParameter.Name == "VALUE" && propertyParameter.Value == "DATE") == 1) { strBuilder.Append(propValue.ToString("yyyyMMdd")); } else { strBuilder.Append(propValue.ToString("yyyyMMddTHHmmss") + (propValue.Kind == DateTimeKind.Utc ? "Z" : "")); } } else if (property is IValue <ActionValues.ActionValue> ) { strBuilder.Append(ActionValues.ToString(((IValue <ActionValues.ActionValue>)property).Value)); } else if (property is IValue <DurationType> ) { strBuilder.Append(((IValue <DurationType>)property).Value); } else if (property is IValue <Period> ) { strBuilder.Append(((IValue <Period>)property).Value); } else if (property is IValue <TimeSpan> ) { strBuilder.Append(((IValue <TimeSpan>)property).Value.ToStringOffset()); } else if (property is IValue <Recur> ) { strBuilder.Append(((IValue <Recur>)property).Value); } else if (property is IValue <IList <DateTime> > ) { var values = ((IValue <IList <DateTime> >)property).Value; var flag = false; var isDate = property.PropertyParameters.Count( propertyParameter => propertyParameter.Name == "VALUE" && propertyParameter.Value == "DATE") == 1; foreach (var value in values) { if (flag) { strBuilder.Append(','); } if (isDate) { strBuilder.Append(value.ToString("yyyyMMdd")); } else { strBuilder.Append(value.ToString("yyyyMMddTHHmmss") + (value.Kind == DateTimeKind.Utc ? "Z" : "")); } flag = true; } } return(strBuilder.SplitLines().ToString()); }