using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Linq;
using DTS.Common.Utilities.Logging;
using DTS.Common.Utils;
// ReSharper disable UnusedVariable
namespace DTS.Common.XMLUtils
{
public static class TestMetadataXml
{
///
/// Return list of files
///
///
///
///
///
public static XDocument GetTestMetadataXml(string path, string file = "", string pattern = "")
{
if (string.IsNullOrEmpty(pattern)) pattern = ".dts";
FileUtils.FileList = new List();
if (!String.IsNullOrEmpty(file))
{ FileUtils.FileList.Add(file); }
else
{ FileUtils.FindFiles(path, pattern); }
return SetTestMetadataType(FileUtils.FileList);
}
///
/// Read all DTS xml files
///
/// DTS xml file list
///
private static XDocument SetTestMetadataType(IEnumerable fileList)
{
try
{
var count = 0;
var x = new XDocument();
x.Add(new XElement("Tests"));
foreach (var file in fileList)
{
try
{
var xTestMetadata = new XElement("TestMetadata");
xTestMetadata.SetAttributeValue("Id", count++.ToString());
using (var reader = new StreamReader(file))
{
var allText = reader.ReadToEnd();
var delimiter = "