private static string GetCustomPropertyChar(PropertyLite propertyValue, WorkflowPropertyType propertyType) { // BluePrintSys.RC.CrossCutting.Logging.Log.Assert( // (propertyValue != null) && propertyValue.SaveState.HasFlag(NodeSaveState.MemoryNode)); if ( /*propertyValue.NodeDeleted ||*/ (((int)PropertyTypePredefined.GroupMask & (int)propertyType.Predefined) != (int)PropertyTypePredefined.CustomGroup)) { return(null); } PropertyPrimitiveType primitiveType; if (propertyType is NumberPropertyType) { primitiveType = PropertyPrimitiveType.Number; } else if (propertyType is DatePropertyType) { primitiveType = PropertyPrimitiveType.Date; } else if (propertyType is TextPropertyType) { primitiveType = PropertyPrimitiveType.Text; } else if (propertyType is UserPropertyType) { primitiveType = PropertyPrimitiveType.User; } else if (propertyType is ChoicePropertyType) { primitiveType = PropertyPrimitiveType.Choice; } // else if (propertyValue is DImagePropertyValue) // { // primitiveType = PropertyPrimitiveType.Image; // } else { // BluePrintSys.RC.CrossCutting.Logging.Log.Assert(false); return(null); } XmlCustomProperties customProperties = new XmlCustomProperties(); XmlCustomProperty customProperty = XmlCustomProperty.CreateAsValue(propertyType.PropertyTypeId, (int)primitiveType); customProperties.CustomProperties.Add(customProperty); if (propertyType is ChoicePropertyType) { List <XmlCustomPropertyValidValue> validValues = customProperty.ValidValues; foreach (int choiceId in propertyValue.ChoiceIds) { var customChoice = (propertyType as ChoicePropertyType).ValidValues .Where(v => v.Sid.Value == choiceId) .Select(v => v.Id).FirstOrDefault().Value; XmlCustomPropertyValidValue validValue = XmlCustomPropertyValidValue.CreateAsValue(customChoice); validValues.Add(validValue); } } return(XmlModelSerializer.SerializeCustomProperties(customProperties)); }
public static string SerializeCustomProperties(XmlCustomProperties customProperties) { if (customProperties == null) { return(null); } StringBuilder stringBuilder = new StringBuilder(0x100); using (XmlWriter writer = XmlWriter.Create(stringBuilder, _writerSettings)) { _customPropertiesSerializer.Serialize(writer, customProperties, _serializerNamespaces); } return(stringBuilder.ToString()); }