Ejemplo n.º 1
0
 private static XElement ConvertToXElement(DataCenterElement obj)
 {
     var element = new XElement(obj.Name);
     foreach (var arg in obj.Attributes)
     {
         element.SetAttributeValue(arg.Name, arg.ValueToString(CultureInfo.InvariantCulture));
     }
     foreach (var child in obj.Children)
     {
         var childElement = ConvertToXElement(child);
         element.Add(childElement);
     }
     return element;
 }
Ejemplo n.º 2
0
        public Dictionary<string, object> GetValues(DataCenterElement dcObject, Func<DataCenterValue, object> projection)
        {
            Dictionary<string, object> values = dcObject.Attributes.ToDictionary(x => x.Name, projection);

            foreach (var child in dcObject.Children)
            {
                if (!values.ContainsKey(child.Name))
                    values.Add(child.Name, new List<Dictionary<string, object>>());

                var childredValues = (List<Dictionary<string, object>>)values[child.Name];
                childredValues.Add(GetValues(child, projection));
            }

            return values;
        }
Ejemplo n.º 3
0
 public Dictionary<string, object> GetValuesAsObjects(DataCenterElement dcObject)
 {
     return GetValues(dcObject, x => x);
 }
Ejemplo n.º 4
0
 public Dictionary<string, object> GetValues(DataCenterElement dcObject)
 {
     return GetValues(dcObject, x => (object) x.ValueToString(CultureInfo.CurrentCulture));
 }