Exemplo n.º 1
0
        /// <summary>
        /// Checks whether the supplied plan name exists in the list of known plans.
        /// This finds names using the current comparison settings, usually ignoring
        /// differences in whitespace, punctuation, etc.
        /// </summary>
        /// <param name="planName">The name of the plan to check for. Does not need to be exact.</param>
        /// <returns>Returns true if the plan name is known to exist.</returns>
        /// <exception cref="ArgumentNullException"/>
        public bool HasPlanName(string planName)
        {
            if (string.IsNullOrEmpty(planName))
            {
                throw new ArgumentNullException(nameof(planName));
            }

            return(PlansLookup.TryGetValue(planName, out var value));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the plans matching a specific plan name.
        /// </summary>
        /// <param name="planName">The planname.</param>
        /// <returns>Returns the list of plans that match the provided name.</returns>
        public List <Plan> GetPlans(string planName)
        {
            if (string.IsNullOrEmpty(planName))
            {
                throw new ArgumentNullException(nameof(planName));
            }

            if (PlansLookup.TryGetValue(planName, out var plans))
            {
                return(plans);
            }

            return(null);
        }
Exemplo n.º 3
0
        public void Reset()
        {
            PlansLookup.Clear();

            NormalVotes.Clear();
            RankedVotes.Clear();
            ApprovalVotes.Clear();

            IdentityVotesLookup.Clear();

            FutureReferences.Clear();
            UndoBuffer.Clear();

            TallyTasks.Clear();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the canonical plan name that matches the requested plan name.
        /// </summary>
        /// <param name="planName">The name of the plan to check for. Does not need to be exact.</param>
        /// <param name="canonicalName">Returns the canonical version of the name, if found.</param>
        /// <returns>Returns true if the requested name is found.</returns>
        /// <exception cref="ArgumentNullException"/>
        public bool TryGetPlanName(string planName, out string canonicalName)
        {
            if (string.IsNullOrEmpty(planName))
            {
                throw new ArgumentNullException(nameof(planName));
            }

            if (PlansLookup.TryGetValue(planName, out var value))
            {
                canonicalName = value.First().Identity.Name;
                return(true);
            }

            canonicalName = null;
            return(false);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the lookup table for plans.
 /// </summary>
 /// <returns>Returns the list of all plans.</returns>
 public IEnumerable <Plan> GetPlans()
 {
     return(PlansLookup.Select(a => a.Value).SelectMany(b => b));
 }