// Copyright (c) 2023 schick Informatik // Description: Static lists used everywhere // using BreCalClient.misc.Model; using System.Collections.Concurrent; using System.Collections.Generic; namespace BreCalClient { public static class BreCalLists { #region Fields private static readonly List aList = new(); private static readonly List mList = new(); private static readonly List pList = new(); private static readonly List tList = new(); private static readonly List terList = new(); private static readonly List _berths = new(); private static List _allBerths = new(); private static List _participants = new(); private static readonly List _ships = new(); private static readonly List _allShips = new(); private readonly static ConcurrentDictionary _shipLookupDict = new(); private readonly static ConcurrentDictionary _berthLookupDict = new(); private readonly static Dictionary _participantLookupDict = new(); /// /// List of TimeRef points /// // TODO: To make this portable the list of texts should come from a configuration file private readonly static List _timeRefs = new List { "ETB", "Geeste", "TN-Weser" }; #endregion #region Properties public static ConcurrentDictionary ShipLookupDict { get { return _shipLookupDict; } } public static ConcurrentDictionary BerthLookupDict { get { return _berthLookupDict; } } public static Dictionary ParticipantLookupDict { get { return _participantLookupDict; } } /// /// Participants that are agents /// public static List Participants_Agent { get { return aList; } } /// /// Participants that are mooring companies /// public static List Participants_Mooring { get { return mList; } } /// /// Participants that are pilots /// public static List Participants_Pilot { get { return pList; } } /// /// Participants that are tug shipping companies /// public static List Participants_Tug { get { return tList; } } /// /// Participants that are terminals /// public static List Participants_Terminal { get { return terList; } } /// /// All participants /// public static List Participants { get { return _participants; } } /// /// All active berths /// public static List Berths { get { return _berths; } } /// /// All berths including deleted berths /// public static List AllBerths { get { return _allBerths; } } /// /// All active ships /// public static List Ships { get { return _ships; } } /// /// All ships including deleted ships /// public static List AllShips { get { return _allShips; } } /// /// List of display values for TimeRef points /// public static List TimeRefs { get { return _timeRefs; } } #endregion #region methods internal static void InitializeParticipants(List participants) { _participants = participants; aList.Clear(); mList.Clear(); pList.Clear(); tList.Clear(); terList.Clear(); foreach (Participant p in participants) { _participantLookupDict[p.Id] = p; if (p.IsTypeFlagSet(Extensions.ParticipantType.AGENCY)) aList.Add(p); if (p.IsTypeFlagSet(Extensions.ParticipantType.MOORING)) mList.Add(p); if (p.IsTypeFlagSet(Extensions.ParticipantType.PILOT)) pList.Add(p); if (p.IsTypeFlagSet(Extensions.ParticipantType.TUG)) tList.Add(p); if (p.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL)) terList.Add(p); } } internal static void InitializeBerths(List berths) { foreach (var berth in berths) { _berthLookupDict[berth.Id] = berth; if(!berth.Deleted) _berths.Add(berth); } _allBerths = berths; } internal static void InitializeShips(List ships) { _ships.Clear(); _allShips.Clear(); foreach (var ship in ships) { ShipModel sm = new(ship); _shipLookupDict[ship.Id] = sm; if (!ship.Deleted) _ships.Add(sm); _allShips.Add(sm); } } #endregion } }