Exemplo n.º 1
0
 public Unit(UserUnit unit)
 {
     SystemName           = unit.NumeratorName;
     ConversionMultiplier = unit.Multiplier;
     ConversionOffset     = unit.Offset;
     DimensionVector      = unit.DimensionVector;
 }
        public static DimensionVector Parse(string s)
        {
            var v        = new DimensionVector();
            var indexOfE = s.IndexOf("E");
            var indexOfL = s.IndexOf("L");
            var indexOfI = s.IndexOf("I");
            var indexOfM = s.IndexOf("M");
            var indexOfH = s.IndexOf("H");
            var indexOfT = s.IndexOf("T");
            var indexOfD = s.IndexOf("D");

            v.AmountOfSubstance = short.Parse(s.Substring(1, indexOfE - 1));
            v.ElectricCurrent   = short.Parse(s.Substring(indexOfE + 1, indexOfL - indexOfE - 1));
            v.Length            = short.Parse(s.Substring(indexOfL + 1, indexOfI - indexOfL - 1));
            v.LuminousIntensity = short.Parse(s.Substring(indexOfI + 1, indexOfM - indexOfI - 1));
            v.Mass          = short.Parse(s.Substring(indexOfM + 1, indexOfH - indexOfM - 1));
            v.Temperature   = short.Parse(s.Substring(indexOfH + 1, indexOfT - indexOfH - 1));
            v.Time          = short.Parse(s.Substring(indexOfT + 1, indexOfD - indexOfT - 1));
            v.Dimensionless = short.Parse(s.Substring(indexOfD + 1));

            return(v);
        }