using System; using System.Collections.Generic; using System.Text; using s = System; using System.Linq; using gt=GlobalType; namespace DomainUtil { public class Participants { gt.IParticipant[] _arrParticipants; s.Collections.Generic.Dictionary<int, int> _dictOfIndexesByID; public Participants(IList<gt.IParticipant> lstParticipants) { IEnumerable<gt.IParticipant> sorted = lstParticipants.OrderBy(o=>o.ID); _arrParticipants = sorted.ToArray(); _dictOfIndexesByID = new Dictionary<int,int>(); int i = -1; foreach(gt.IParticipant aParticipant in sorted) { i++; _dictOfIndexesByID.Add(aParticipant.ID, i); } } public int IndexFromID(int iID) { return _dictOfIndexesByID[iID]; } public string NameFromIndex(int iIndex) { return _arrParticipants[iIndex].Name; } public string NameFromID(int iID) { return NameFromIndex(IndexFromID(iID)); } public int IDFromIndex(int iIndex) { return _arrParticipants[iIndex].ID; } public int Count { get { return _arrParticipants.Length; } } public int[] GetArrayOfIDs() { int[] arr = new int[_arrParticipants.Length]; for (int i = 0; i < _arrParticipants.Length; i++) { arr[i] = _arrParticipants[i].ID; } return arr; } public gt.IParticipant[] GetArryOfObjects() { gt.IParticipant[] arr = new gt.IParticipant[_arrParticipants.Length]; for (int i = 0; i < _arrParticipants.Length; i++) { arr[i] = _arrParticipants[i]; } return arr; } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)