using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace CobXmlSupport { public class IndStatus { private List presentInds = null; private int returns = 0; private string[] newInds = null; public IndStatus() { presentInds = new List(); } /// /// Bearbetar status av förekommande indexvariabler i aktuell xml-struktur /// /// innehåller en string array med aktuella index för den kommande variabeln 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 news = new List(); 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 addedStrs = new List(); 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; } } } }