63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
using DTS.Common.Import.Interfaces;
|
|
using DTS.Common.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Xml;
|
|
|
|
namespace DTS.Common.Import.XML
|
|
{
|
|
public class XMLParseGlobalSettings : XMLParseBase
|
|
{
|
|
public XMLParseGlobalSettings(XmlElement root, double importedVersion, Func<bool> isCancelled = null) : base(root, importedVersion, isCancelled)
|
|
{
|
|
}
|
|
public IImportNotification ImportNotification { get; set; }
|
|
public override void Parse(ref ImportObject importObject)
|
|
{
|
|
importObject.AssignGlobalSettings(ParseGlobalSettings(_root));
|
|
}
|
|
|
|
private Dictionary<string, string> ParseGlobalSettings(XmlElement root)
|
|
{
|
|
Dictionary<string, string> settings = new Dictionary<string, string>();
|
|
|
|
foreach (var child in root.ChildNodes)
|
|
{
|
|
if (IsCancelled()) { return settings; }
|
|
if (child is XmlElement)
|
|
{
|
|
GetGlobalSetting(child as XmlElement, ref settings);
|
|
}
|
|
}
|
|
return settings;
|
|
}
|
|
|
|
private void GetGlobalSetting(XmlElement node, ref Dictionary<string, string> settings)
|
|
{
|
|
string sName = "", sValue = "";
|
|
foreach (var child in node.ChildNodes)
|
|
{
|
|
if (child is XmlElement)
|
|
{
|
|
var childNode = child as XmlElement;
|
|
switch (childNode.Name)
|
|
{
|
|
case "SettingName":
|
|
sName = childNode.InnerText;
|
|
break;
|
|
case "SettingValue":
|
|
sValue = childNode.InnerText;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(sName))
|
|
{
|
|
settings[sName] = sValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|