XAttributeList Assign(IXAttributable element, XAttributeList definedAttribute) { XAttributeList attr = (XAttributeList)definedAttribute.Clone(); element.GetAttributes().Add(definedAttribute.Key, attr); return(attr); }
public void AssignNestedValues(IXAttributable element, Dictionary <List <string>, T> amounts) { foreach (List <string> keys in amounts.Keys) { AssignNestedValuesPrivate(element, keys, amounts[keys]); } }
void Assign(IXAttributable element, string definedAttribute, XID value) { XAttributeID attr = (XAttributeID)ATTR_PID.Clone(); attr.Value = value; element.GetAttributes().Add(QualifiedName(definedAttribute), attr); }
void AssignNestedValuesPrivate(IXAttributable element, List <string> keys, T value) { if (keys.Count == 0) { if (element is XAttribute) { AssignValue((XAttribute)element, value); } } else { String key = keys[0]; List <string> keysTail = keys.GetRange(1, keys.Count); XAttribute attr; if (element.GetAttributes().ContainsKey(key)) { attr = element.GetAttributes()[key]; } else { attr = (XFactoryRegistry.Instance.CurrentDefault).CreateAttributeLiteral(key, "", null); element.GetAttributes().Add(key, attr); } AssignNestedValuesPrivate((IXAttributable)attr, keysTail, value); } }
IXAttributeBoolean Assign(IXAttributable element, IXAttributeBoolean definedAttribute, bool value) { XAttributeBoolean attr = (XAttributeBoolean)definedAttribute.Clone(); attr.Value = value; element.GetAttributes().Add(definedAttribute.Key, attr); return(attr); }
IXAttributeDiscrete Assign(IXAttributable element, XAttributeDiscrete definedAttribute, long value) { XAttributeDiscrete attr = (XAttributeDiscrete)definedAttribute.Clone(); attr.Value = value; element.GetAttributes().Add(definedAttribute.Key, attr); return(attr); }
XAttributeContinuous Assign(IXAttributable element, XAttributeContinuous definedAttribute, double value) { XAttributeContinuous attr = (XAttributeContinuous)definedAttribute.Clone(); attr.Value = value; element.GetAttributes().Add(definedAttribute.Key, attr); return(attr); }
XAttributeLiteral Assign(IXAttributable element, XAttributeLiteral definedAttribute, SoftwareEventType value) { XAttributeLiteral attr = (XAttributeLiteral)definedAttribute.Clone(); attr.Value = GetSoftwareEventTypeName(value); element.GetAttributes().Add(definedAttribute.Key, attr); return(attr); }
void AssignCurrencyPrivate(IXAttributable element, string currency) { if ((currency != null) && (currency.Trim().Length > 0)) { XAttributeLiteral attr = (XAttributeLiteral)ATTR_CURRENCY.Clone(); attr.Value = currency; element.GetAttributes().Add(QualifiedName(KEY_CURRENCY), 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); } }
double Extract(IXAttributable element, string definedAttribute, double defaultValue) { XAttribute attribute = element.GetAttributes()[definedAttribute]; if (attribute == null) { return(defaultValue); } return(((XAttributeContinuous)attribute).Value); }
XID Extract(IXAttributable element, string definedAttribute, XID defaultValue) { XAttribute attribute = element.GetAttributes()[QualifiedName(definedAttribute)]; if (attribute == null) { return(defaultValue); } return(((XAttributeID)attribute).Value); }
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); } }
double ExtractTotalPrivate(IXAttributable element) { XAttribute attribute = element.GetAttributes()[QualifiedName(KEY_TOTAL)]; if (attribute == null) { return(-1); } return(((XAttributeContinuous)attribute).Value); }
bool Extract(IXAttributable element, string definedAttribute, bool defaultValue) { XAttribute attribute = element.GetAttributes()[definedAttribute]; if (attribute == null) { return(defaultValue); } return(((XAttributeBoolean)attribute).Value); }
string Extract(IXAttributable element, string definedAttribute, string defaultValue) { XAttribute attribute = element.GetAttributes()[definedAttribute]; if (attribute == null) { return(defaultValue); } return(((XAttributeLiteral)attribute).Value); }
string ExtractCurrencyPrivate(IXAttributable element) { XAttribute attribute = element.GetAttributes()[QualifiedName(KEY_CURRENCY)]; if (attribute == null) { return(null); } return(((XAttributeLiteral)attribute).Value); }
/// <summary> /// Registers all attributes of a given attributable, i.e. model type hierarchy /// element, in the given attribute info registry. /// </summary> /// <param name="attributeInfo">Attribute info registry to use for registration.</param> /// <param name="attributable">Attributable whose attributes to register.</param> protected void RegisterAttributes(XAttributeInfo attributeInfo, IXAttributable attributable) { if (attributable.HasAttributes()) { foreach (XAttribute attribute in attributable.GetAttributes().Values) { attributeInfo.Register(attribute); RegisterAttributes(this.metaAttributeInfo, (IXAttributable)attribute); } } }
public IList <Uri> ExtractModelReferenceURIs(IXAttributable target) { IList <string> refStrings = ExtractModelReferences(target); IList <Uri> refURIs = new List <Uri>(refStrings.Count); foreach (String refString in refStrings) { refURIs.Add(new UriBuilder(refString).Uri); } return(refURIs); }
SoftwareEventType Extract(IXAttributable element, string definedAttribute, SoftwareEventType defaultValue) { XAttribute attribute = element.GetAttributes()[definedAttribute]; if (attribute == null) { return(defaultValue); } return(ParseSoftwareEventType(((XAttributeLiteral)attribute).Value)); }
List <XAttribute> Extract(IXAttributable element, string definedAttribute, List <XAttribute> defaultValue) { XAttribute attribute = element.GetAttributes()[definedAttribute]; if (attribute == null) { return(defaultValue); } return(((XAttributeList)attribute).GetCollection()); }
public XID ExtractID(IXAttributable element) { try { return(((XAttributeID)element.GetAttributes()[QualifiedName(KEY_ID)]).Value); } catch (KeyNotFoundException) { XLogging.Log("Key '" + QualifiedName(KEY_ID) + "' not available", XLogging.Importance.WARNING); return(null); } }
public void AssignValues(IXAttributable element, Dictionary <String, T> values) { Dictionary <List <string>, T> nestedValues = new Dictionary <List <string>, T>(); foreach (string key in values.Keys) { List <string> keys = new List <string>(); keys.Add(key); nestedValues.Add(keys, values[key]); } AssignNestedValues(element, nestedValues); }
public Dictionary <List <string>, T> ExtractNestedValues(IXAttributable element) { Dictionary <List <string>, T> nestedValues = new Dictionary <List <string>, T>(); foreach (XAttribute attr in element.GetAttributes().Values) { List <string> keys = new List <string>(); keys.Add(attr.Key); ExtractNestedValuesPrivate(attr, nestedValues, keys); } return(nestedValues); }
XAttributeLiteral Assign(IXAttributable element, XAttributeLiteral definedAttribute, string value) { if (value != null) { XAttributeLiteral attr = (XAttributeLiteral)definedAttribute.Clone(); attr.Value = value; element.GetAttributes().Add(definedAttribute.Key, attr); return(attr); } return(null); }
public IDictionary <String, T> ExtractValues(IXAttributable element) { Dictionary <String, T> values = new Dictionary <string, T>(); Dictionary <List <string>, T> nestedValues = ExtractNestedValues(element); foreach (List <string> keys in nestedValues.Keys) { if (keys.Count == 1) { values.Add(keys[0], nestedValues[keys]); } } return(values); }
public IList <string> ExtractModelReferences(IXAttributable target) { IList <string> modelReferences = new List <string>(); XAttributeLiteral modelReferenceAttribute = (XAttributeLiteral)target.GetAttributes()[QualifiedName(KEY_MODELREFERENCE)]; if (modelReferenceAttribute != null) { String refString = modelReferenceAttribute.Value.Trim(); foreach (Match m in Regex.Matches(refString, @"\\s")) { modelReferences.Add(m.Value.Trim()); } } return(modelReferences); }
public void AssignModelReferenceUris(IXAttributable target, List <Uri> modelReferenceURIs) { StringBuilder sb = new StringBuilder(); foreach (Uri mUri in modelReferenceURIs) { sb.Append(mUri.ToString()); sb.Append(" "); } if (sb.ToString().Trim().Length > 0) { XAttributeLiteral attr = (XAttributeLiteral)ATTR_MODELREFERENCE.Clone(); attr.Value = sb.ToString().Trim(); target.GetAttributes().Add(QualifiedName(KEY_MODELREFERENCE), attr); } }
/// <summary> /// First call made when visiting an attribute. /// </summary> /// <param name="attr">The attribute to visit..</param> /// <param name="parent">The element (log, trace, event or attribute) containing /// the attribute.</param> public abstract void VisitAttributePre(XAttribute attr, IXAttributable parent);
bool Remove(IXAttributable element, string definedAttribute) { return(element.GetAttributes().Remove(definedAttribute)); }