// Copyright (c) 2023 schick Informatik // Description: some helpers // using BreCalClient.misc.Model; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BreCalClient { internal static class Extensions { #region Enum /// /// Copied from models clunky I know /// [Flags] public enum ParticipantType { [Description("not assigned")] NONE = 0, [Description("BSMD")] BSMD = 1, [Description("Terminal")] TERMINAL = 2, [Description("Lotsen")] PILOT = 4, [Description("Agentur")] AGENCY = 8, [Description("Festmacher")] MOORING = 16, [Description("Hafenamt")] PORT_ADMINISTRATION = 32, [Description("Schlepper")] TUG = 64, } #endregion #region public helper public static bool IsFlagSet(this Participant participant, ParticipantType flag) { return (participant.Type & (uint)flag) != 0; } public static void SetFlag(this Participant participant, bool value, ParticipantType flag) { if (value) participant.Type |= (int)flag; else participant.Type &= (int)~flag; } #endregion } }