コード例 #1
0
ファイル: XmlDumper.cs プロジェクト: Koushi009/TeraDataTools
 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;
 }
コード例 #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;
        }
コード例 #3
0
 public Dictionary<string, object> GetValuesAsObjects(DataCenterElement dcObject)
 {
     return GetValues(dcObject, x => x);
 }
コード例 #4
0
 public Dictionary<string, object> GetValues(DataCenterElement dcObject)
 {
     return GetValues(dcObject, x => (object) x.ValueToString(CultureInfo.CurrentCulture));
 }