Example #1
0
        public static bool AddOrReplaceUnitAdder(string from, string to, double adder)
        {
            string key    = $"{from}-{to}";
            bool   exists = UnitAdders.ContainsKey(key);

            if (exists)
            {
                UnitAdders[key] = adder;
            }
            else
            {
                UnitAdders.Add(key, adder);
            }
            return(UnitAdders.ContainsKey(key));
        }
Example #2
0
        public static double GetUnitAdder(string from, string to)
        {
            double adder;

            if (from == to)
            {
                return(0);
            }
            if (UnitAdders.TryGetValue(from + "-" + to, out adder))
            {
                return(adder);
            }
            if (UnitAdders.TryGetValue(to + "-" + from, out adder))
            {
                return(-adder *GetUnitMultiplier(from, to));
            }
            return(0);
        }