예제 #1
0
        XAttributeList Assign(IXAttributable element, XAttributeList definedAttribute)
        {
            XAttributeList attr = (XAttributeList)definedAttribute.Clone();

            element.GetAttributes().Add(definedAttribute.Key, attr);
            return(attr);
        }
예제 #2
0
 public void AssignNestedValues(IXAttributable element, Dictionary <List <string>, T> amounts)
 {
     foreach (List <string> keys in amounts.Keys)
     {
         AssignNestedValuesPrivate(element, keys, amounts[keys]);
     }
 }
예제 #3
0
        void Assign(IXAttributable element, string definedAttribute, XID value)
        {
            XAttributeID attr = (XAttributeID)ATTR_PID.Clone();

            attr.Value = value;
            element.GetAttributes().Add(QualifiedName(definedAttribute), attr);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        IXAttributeBoolean Assign(IXAttributable element, IXAttributeBoolean definedAttribute, bool value)
        {
            XAttributeBoolean attr = (XAttributeBoolean)definedAttribute.Clone();

            attr.Value = value;
            element.GetAttributes().Add(definedAttribute.Key, attr);
            return(attr);
        }
예제 #6
0
        IXAttributeDiscrete Assign(IXAttributable element, XAttributeDiscrete definedAttribute, long value)
        {
            XAttributeDiscrete attr = (XAttributeDiscrete)definedAttribute.Clone();

            attr.Value = value;
            element.GetAttributes().Add(definedAttribute.Key, attr);
            return(attr);
        }
예제 #7
0
        XAttributeContinuous Assign(IXAttributable element, XAttributeContinuous definedAttribute, double value)
        {
            XAttributeContinuous attr = (XAttributeContinuous)definedAttribute.Clone();

            attr.Value = value;
            element.GetAttributes().Add(definedAttribute.Key, attr);
            return(attr);
        }
예제 #8
0
        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);
        }
예제 #9
0
 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);
     }
 }
예제 #10
0
 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);
     }
 }
예제 #11
0
        double Extract(IXAttributable element, string definedAttribute, double defaultValue)
        {
            XAttribute attribute = element.GetAttributes()[definedAttribute];

            if (attribute == null)
            {
                return(defaultValue);
            }
            return(((XAttributeContinuous)attribute).Value);
        }
예제 #12
0
        XID Extract(IXAttributable element, string definedAttribute, XID defaultValue)
        {
            XAttribute attribute = element.GetAttributes()[QualifiedName(definedAttribute)];

            if (attribute == null)
            {
                return(defaultValue);
            }
            return(((XAttributeID)attribute).Value);
        }
예제 #13
0
        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);
            }
        }
예제 #14
0
        double ExtractTotalPrivate(IXAttributable element)
        {
            XAttribute attribute = element.GetAttributes()[QualifiedName(KEY_TOTAL)];

            if (attribute == null)
            {
                return(-1);
            }
            return(((XAttributeContinuous)attribute).Value);
        }
예제 #15
0
        bool Extract(IXAttributable element, string definedAttribute, bool defaultValue)
        {
            XAttribute attribute = element.GetAttributes()[definedAttribute];

            if (attribute == null)
            {
                return(defaultValue);
            }
            return(((XAttributeBoolean)attribute).Value);
        }
예제 #16
0
        string Extract(IXAttributable element, string definedAttribute, string defaultValue)
        {
            XAttribute attribute = element.GetAttributes()[definedAttribute];

            if (attribute == null)
            {
                return(defaultValue);
            }
            return(((XAttributeLiteral)attribute).Value);
        }
예제 #17
0
        string ExtractCurrencyPrivate(IXAttributable element)
        {
            XAttribute attribute = element.GetAttributes()[QualifiedName(KEY_CURRENCY)];

            if (attribute == null)
            {
                return(null);
            }
            return(((XAttributeLiteral)attribute).Value);
        }
예제 #18
0
파일: XLogInfo.cs 프로젝트: kroehne/LogFSM
 /// <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);
         }
     }
 }
예제 #19
0
        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);
        }
예제 #20
0
        SoftwareEventType Extract(IXAttributable element, string definedAttribute,
                                  SoftwareEventType defaultValue)
        {
            XAttribute attribute = element.GetAttributes()[definedAttribute];

            if (attribute == null)
            {
                return(defaultValue);
            }
            return(ParseSoftwareEventType(((XAttributeLiteral)attribute).Value));
        }
예제 #21
0
        List <XAttribute> Extract(IXAttributable element, string definedAttribute,
                                  List <XAttribute> defaultValue)
        {
            XAttribute attribute = element.GetAttributes()[definedAttribute];

            if (attribute == null)
            {
                return(defaultValue);
            }
            return(((XAttributeList)attribute).GetCollection());
        }
예제 #22
0
 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);
     }
 }
예제 #23
0
        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);
        }
예제 #24
0
        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);
        }
예제 #25
0
        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);
        }
예제 #26
0
        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);
        }
예제 #27
0
        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);
        }
예제 #28
0
        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);
            }
        }
예제 #29
0
파일: XVisitor.cs 프로젝트: kroehne/LogFSM
 /// <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);
예제 #30
0
 bool Remove(IXAttributable element, string definedAttribute)
 {
     return(element.GetAttributes().Remove(definedAttribute));
 }