void Assign(IXAttributable element, string definedAttribute, XID value) { XAttributeID attr = (XAttributeID)ATTR_PID.Clone(); attr.Value = value; element.GetAttributes().Add(QualifiedName(definedAttribute), attr); }
public void AssignID(IXAttributable element, XID id) { if (id != null) { XAttributeID attr = (XAttributeID)ATTR_ID.Clone(); attr.Value = id; element.GetAttributes().Add(QualifiedName(KEY_ID), attr); } }
/// <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!"); }