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); } } }
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); }
public void Set(BugType bugType, BugTypeWeight bugTypeWeight, double value) { int key = GetKey(bugType, bugTypeWeight); _bugTypeWeights[key] = value; }
public double Get(BugType bugType, BugTypeWeight bugTypeWeight) { int key = GetKey(bugType, bugTypeWeight); return(_bugTypeWeights[key]); }
private static int GetKey(BugType bugType, BugTypeWeight bugTypeWeight) { return(((int)bugType * NumBugTypeWeights) + (int)bugTypeWeight); }
public static string GetKeyName(BugType bugType, BugTypeWeight bugTypeWeight) { return(string.Join(KeySeperator, bugType.ToString(), bugTypeWeight.ToString())); }