public object Clone(int Offset, int length) { ThreadSafeCollection <T> col = new ThreadSafeCollection <T>(); lock (threadLock) { for (int i = 0; i <= length; i++) { col.Add(this[i + Offset]); } } return(col); }
public static ThreadSafeCollection <VSOP87> Load(string Path, ThreadSafeCollection <VSOP87> vc) { TextReader tr = new StreamReader(Path); //ThreadSafeCollection<VSOP87> vc = new ThreadSafeCollection<VSOP87>(); bool reading = true; string currentSeries = ""; string currentPlanet = ""; while (reading) { string s = tr.ReadLine(); if (s != null) { s = s.Trim(); s = s.Replace(" ", " "); s = s.Replace(" ", " "); s = s.Replace(" ", " "); string[] str = s.Split(new Char[] { ' ' }); if (str[0] == "VSOP87") { currentPlanet = str[3]; currentSeries = createSeries(str[5], str[7]); } else { int len = str.Length; VSOP87 v87 = new VSOP87(); v87.Planet = currentPlanet; v87.Series = currentSeries; v87.A = Convert.ToDecimal(str[len - 3]); v87.B = Convert.ToDecimal(str[len - 2]); v87.C = Convert.ToDecimal(str[len - 1]); vc.Add(v87); } } else { reading = false; } } return((ThreadSafeCollection <VSOP87>)vc.Clone()); }
public object Clone(bool clear) { ThreadSafeCollection <T> col = new ThreadSafeCollection <T>(); lock (threadLock) { foreach (T item in this.List) { if ((item != null)) { col.Add(item); } } if (clear) { this.List.Clear(); } return((object)col); } }