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; }
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; }
public Dictionary<string, object> GetValuesAsObjects(DataCenterElement dcObject) { return GetValues(dcObject, x => x); }
public Dictionary<string, object> GetValues(DataCenterElement dcObject) { return GetValues(dcObject, x => (object) x.ValueToString(CultureInfo.CurrentCulture)); }