Example #1
0
        public static void IterateOverWeights(Action <BugType, BugTypeWeight> action)
        {
            if (null == action)
            {
                throw new ArgumentNullException("action");
            }

            for (int bugTypeInt = 0; bugTypeInt < EnumUtils.NumBugTypes; bugTypeInt++)
            {
                BugType bugType = (BugType)bugTypeInt;
                for (int bugTypeWeightInt = 0; bugTypeWeightInt < NumBugTypeWeights; bugTypeWeightInt++)
                {
                    BugTypeWeight bugTypeWeight = (BugTypeWeight)bugTypeWeightInt;

                    action(bugType, bugTypeWeight);
                }
            }
        }
Example #2
0
        public static bool TryParseKeyName(string key, out BugType bugType, out BugTypeWeight bugTypeWeight)
        {
            if (!string.IsNullOrWhiteSpace(key))
            {
                try
                {
                    string[] split = key.Split(KeySeperator[0]);

                    if (Enum.TryParse(split[split.Length - 1], out bugTypeWeight))
                    {
                        if (Enum.TryParse(split[split.Length - 2], out bugType))
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception) { }
            }

            bugType       = default(BugType);
            bugTypeWeight = default(BugTypeWeight);
            return(false);
        }
Example #3
0
        public void Set(BugType bugType, BugTypeWeight bugTypeWeight, double value)
        {
            int key = GetKey(bugType, bugTypeWeight);

            _bugTypeWeights[key] = value;
        }
Example #4
0
        public double Get(BugType bugType, BugTypeWeight bugTypeWeight)
        {
            int key = GetKey(bugType, bugTypeWeight);

            return(_bugTypeWeights[key]);
        }
Example #5
0
 private static int GetKey(BugType bugType, BugTypeWeight bugTypeWeight)
 {
     return(((int)bugType * NumBugTypeWeights) + (int)bugTypeWeight);
 }
Example #6
0
 public static string GetKeyName(BugType bugType, BugTypeWeight bugTypeWeight)
 {
     return(string.Join(KeySeperator, bugType.ToString(), bugTypeWeight.ToString()));
 }