public long CalculateResistorValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor) { long CalculatedValue; BandA _bandA; BandB _bandB = 0; BandC _bandC = 0; bool IsValidColorCodes = (Enum.TryParse <BandA>(bandAColor, out _bandA) && Enum.TryParse <BandB>(bandBColor, out _bandB) && Enum.TryParse <BandC>(bandCColor, out _bandC)); CalculatedValue = IsValidColorCodes ? (long)(Extensions.GetColorAppenderValue(_bandA, _bandB) * _bandC.GetAttribute <MultiplierAttribute>().Multiplier) : throw new InvalidOperationException("Color Codes are not Valid"); return(CalculatedValue); }
public static int GetColorAppenderValue(BandA bandA, BandB bandB) { bandA = bandA + 1; return(Convert.ToInt32((((int)bandA).ToString() + ((int)bandB).ToString()))); }