public static void AddConversion(UnitConversion conv)
 {
     conversions.Add(conv);
 }
 public static UnitConversion Chain(UnitConversion left, UnitConversion right)
 {
     return(new UnitConversion(left.from, right.to,
                               left.preAdjust + left.postAdjust / left.scale + right.preAdjust / left.scale,
                               left.scale * right.scale, right.postAdjust));
 }
        private static void HandleConversion(XmlReader reader)
        {
            string fromUnit = reader.GetAttribute("fromUnit", "http://www.cornellracing.com/Units.xsd");
            string toUnit = reader.GetAttribute("toUnit", "http://www.cornellracing.com/Units.xsd");

            double preAdj = 0;
            double postAdj = 0;
            double scale = 1;

            bool doRead = true;

            while (!doRead || reader.Read()) {
                if (reader.NodeType == XmlNodeType.EndElement) {
                    UnitConversion uc = new UnitConversion(GetUnit(fromUnit), GetUnit(toUnit), preAdj, scale, postAdj);
                    AddConversion(uc);
                    return;
                }
                else if (reader.NodeType == XmlNodeType.Element) {
                    if (reader.LocalName == "scale") {
                        doRead = false;
                        scale = reader.ReadElementContentAsDouble();
                    }
                    else if (reader.LocalName == "offset") {
                        string prePost = reader.GetAttribute("order", "http://www.cornellracing.com/Units.xsd");
                        if (prePost == "pre") {
                            doRead = false;
                            preAdj = reader.ReadElementContentAsDouble();
                        }
                        else if (prePost == "post") {
                            doRead = false;
                            postAdj = reader.ReadElementContentAsDouble();
                        }
                    }
                }
            }
        }
 public static void AddConversion(UnitConversion conv)
 {
     conversions.Add(conv);
 }
 public static UnitConversion Chain(UnitConversion left, UnitConversion right)
 {
     return new UnitConversion(left.from, right.to,
         left.preAdjust + left.postAdjust / left.scale + right.preAdjust / left.scale,
         left.scale * right.scale, right.postAdjust);
 }