Files
CobXml/CobXmlSupport/IndStatus.cs

117 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace CobXmlSupport
{
public class IndStatus
{
private List<string> presentInds = null;
private int returns = 0;
private string[] newInds = null;
public IndStatus()
{
presentInds = new List<string>();
}
/// <summary>
/// Bearbetar status av förekommande indexvariabler i aktuell xml-struktur
/// </summary>
/// <param name="new_Inds">innehåller en string array med aktuella index för den kommande variabeln</param>
public void handleStatus(string[] new_Inds)
{
Debug.WriteLine("------- present indexs -------");
foreach (string prind in presentInds.ToArray())
{
Debug.Write(prind + ", ");
}
Debug.WriteLine("");
Debug.WriteLine("------- new indexs -------");
if (new_Inds != null)
{
foreach (string nind in new_Inds)
{
Debug.Write(nind + ", ");
}
Debug.WriteLine("");
}
else
Debug.WriteLine(" = null ");
returns = 0;
List<string> news = new List<string>();
if (new_Inds != null) news.AddRange(new_Inds);
foreach (string tmpStr in presentInds.ToArray())
{
if (news.Contains(tmpStr)) { }
else
{
presentInds.Remove(tmpStr);
returns += 1;
}
}
List<string> addedStrs = new List<string>();
if (new_Inds != null)
{
foreach (string tmpInStr in new_Inds)
{
if (presentInds.Contains(tmpInStr)) { }
else
{
presentInds.Add(tmpInStr);
addedStrs.Add(tmpInStr);
}
}
}
if (addedStrs.Count > 0)
{
newInds = addedStrs.ToArray();
}
else newInds = null;
Debug.WriteLine("------- returns -------");
Debug.Write(returns);
Debug.WriteLine("");
Debug.WriteLine("------- tillagda Inds -------");
if (newInds != null)
{
foreach (string tlind in newInds)
{
Debug.Write(tlind + ", ");
}
Debug.WriteLine("");
}
else
Debug.WriteLine(" = null ");
}
public int Returns
{
get
{
return returns;
}
}
public string[] NewInds
{
get
{
return newInds;
}
}
}
}