Files
DP44/Common/DTS.Common.Import/.svn/pristine/f7/f7bd48d21109634d1b87c0df50431e2c92ab4ad2.svn-base

49 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
using DTS.Common.Import.Interfaces;
using System;
using System.Collections.Generic;
using System.Xml;
namespace DTS.Common.Import.XML
{
public abstract class XMLParseBase : IParseVariant
{
protected static readonly Dictionary<int, int> _dasIdMapping = new Dictionary<int, int>();
//Use string to handle both new (Id (int.ToString())) and old (Name (string)) exports
protected static readonly Dictionary<string, int> _groupIdMapping = new Dictionary<string, int>();
protected static readonly Dictionary<int, int> _sensorIdMapping = new Dictionary<int, int>();
protected static readonly Dictionary<long, long> _channelIdMapping = new Dictionary<long, long>();
protected double _importedVersion;
protected readonly Func<bool> IsCancelled;
protected readonly XmlElement _root;
protected XmlWriter _writer;
protected bool _skipNormalizing;
private readonly XmlDocument _doc;
public string FileName { get; set; }
public abstract void Parse(ref ImportObject importObject);
protected XMLParseBase(XmlElement root, double importedVersion, Func<bool> isCancelled = null, bool skipNormalizing = false)
{
_importedVersion = importedVersion;
IsCancelled = isCancelled == null ? () => false : isCancelled;
_root = root;
_skipNormalizing = skipNormalizing;
_doc = new XmlDocument();
_writer = _doc.CreateNavigator().AppendChild();
}
protected XmlElement GetXmlElement()
{
_writer.Close();
return _doc.DocumentElement;
}
}
}