public static EventProperty GetEventProperty(ExtentionPropertyDto property) { return(new EventProperty() { Id = Guid.NewGuid(), Name = property.Name, Value = property.Value, DataType = property.Type }); }
public static LogProperty GetLogProperty(ExtentionPropertyDto property) { if (property == null) { return(null); } return(new LogProperty() { Id = Guid.NewGuid(), DataType = property.Type, Name = property.Name, Value = property.Value }); }
public static Zidium.Core.Api.ExtentionPropertyDto ConvertToCore(ExtentionPropertyDto property) { if (property == null) { return(null); } var type = ParseCoreDataType(property.Type); return(new Zidium.Core.Api.ExtentionPropertyDto() { Name = property.Name, Value = property.Value, Type = type }); }
public static ExtentionProperty GetExtentionPropertyFromDto(ExtentionPropertyDto propertyDto) { if (propertyDto == null) { return(null); } if (string.IsNullOrEmpty(propertyDto.Name)) { return(null); } var typeEnum = GetDataType(propertyDto.Type); object valueObj = null; if (string.IsNullOrEmpty(propertyDto.Value) == false) { if (typeEnum == DataType.Binary) { valueObj = Convert.FromBase64String(propertyDto.Value); } else if (typeEnum == DataType.Boolean) { valueObj = XmlConvert.ToBoolean(propertyDto.Value); } else if (typeEnum == DataType.DateTime) { valueObj = XmlConvert.ToDateTime(propertyDto.Value, XmlDateTimeSerializationMode.Local); } else if (typeEnum == DataType.Double) { valueObj = XmlConvert.ToDouble(propertyDto.Value); } else if (typeEnum == DataType.Int32) { valueObj = XmlConvert.ToInt32(propertyDto.Value); } else if (typeEnum == DataType.Int64) { valueObj = XmlConvert.ToInt64(propertyDto.Value); } else if (typeEnum == DataType.String) { valueObj = propertyDto.Value; } else if (typeEnum == DataType.Guid) { valueObj = XmlConvert.ToGuid(propertyDto.Value); } else if (typeEnum == DataType.Unknown) { valueObj = propertyDto.Value; } else { throw new Exception("Неизвестное значение DataType: " + typeEnum); } } return(new ExtentionProperty(propertyDto.Name) { Value = new ExtentionPropertyValue() { Value = valueObj, DataType = typeEnum } }); }