XAttributeContinuous Assign(IXAttributable element, XAttributeContinuous definedAttribute, double value) { XAttributeContinuous attr = (XAttributeContinuous)definedAttribute.Clone(); attr.Value = value; element.GetAttributes().Add(definedAttribute.Key, attr); return(attr); }
public void AssignAmount(XAttribute attribute, double amount) { if (amount > 0.0D) { XAttributeContinuous attr = (XAttributeContinuous)ATTR_AMOUNT.Clone(); attr.Value = amount; attribute.GetAttributes().Add(QualifiedName(KEY_AMOUNT), attr); } }
void AssignTotalPrivate(IXAttributable element, double total) { if (total > 0.0D) { XAttributeContinuous attr = (XAttributeContinuous)ATTR_TOTAL.Clone(); attr.Value = total; element.GetAttributes().Add(QualifiedName(KEY_TOTAL), attr); } }
public double ExtractAmount(XAttributeContinuous attribute) { XAttributeContinuous attr = (XAttributeContinuous)attribute.GetAttributes()[QualifiedName(KEY_AMOUNT)]; if (attr == null) { return(-1); } return(attr.Value); }
/// <summary> /// Composes the appropriate attribute type from the string-based information /// found, e.g., in XML serializations. /// </summary> /// <returns>An appropriate attribute.</returns> /// <param name="factory">Factory to use for creating the attribute.</param> /// <param name="key">Key of the attribute.</param> /// <param name="value">Value of the attribute.</param> /// <param name="type">Type string of the attribute.</param> /// <param name="extension">Extension of the attribute (can be <code>null</code>).</param> public static XAttribute ComposeAttribute(IXFactory factory, string key, string value, string type, XExtension extension) { type = type.Trim(); if (type.Equals("LIST", StringComparison.CurrentCultureIgnoreCase)) { XAttributeList attr = factory.CreateAttributeList(key, extension); return(attr); } if (type.Equals("CONTAINER", StringComparison.CurrentCultureIgnoreCase)) { XAttributeContainer attr = factory.CreateAttributeContainer(key, extension); return(attr); } if (type.Equals("LITERAL", StringComparison.CurrentCultureIgnoreCase)) { XAttributeLiteral attr = factory.CreateAttributeLiteral(key, value, extension); return(attr); } if (type.Equals("BOOLEAN", StringComparison.CurrentCultureIgnoreCase)) { XAttributeBoolean attr = factory.CreateAttributeBoolean(key, bool.Parse(value), extension); return(attr); } if (type.Equals("CONTINUOUS", StringComparison.CurrentCultureIgnoreCase)) { XAttributeContinuous attr = factory.CreateAttributeContinuous(key, double.Parse(value), extension); return(attr); } if (type.Equals("DISCRETE", StringComparison.CurrentCultureIgnoreCase)) { XAttributeDiscrete attr = factory.CreateAttributeDiscrete(key, long.Parse(value), extension); return(attr); } if (type.Equals("TIMESTAMP", StringComparison.CurrentCultureIgnoreCase)) { IXAttributeTimestamp attr; try { attr = factory.CreateAttributeTimestamp(key, DateTime.Parse(value), extension); } catch (FormatException) { throw new InvalidOperationException("OpenXES: could not parse date-time attribute. Value: " + value); } return((XAttributeTimestamp)attr); } if (type.Equals("ID", StringComparison.CurrentCultureIgnoreCase)) { XAttributeID attr = factory.CreateAttributeID(key, XID.Parse(value), extension); return(attr); } throw new InvalidOperationException("OpenXES: could not parse attribute type!"); }