Ejemplo n.º 1
0
 static public MeasurementUnit GetMeasurementUnit(string[,] words)
 {
     try
     {
         var        unitList   = MeasurementUnitDictionary.MeasurementUnitNames();
         LengthUnit lengthUnit = LengthUnit.MICRON;
         var        inputUnit  = new MeasurementUnit(lengthUnit);
         foreach (string unitStr in unitList)
         {
             for (int i = 0; i < words.GetLength(0); i++)
             {
                 for (int j = 0; j < words.GetLength(1); j++)
                 {
                     string upperw = words[i, j].ToUpper();
                     if (upperw.Contains(unitStr))
                     {
                         Enum.TryParse(unitStr, out lengthUnit);
                         inputUnit = new MeasurementUnit(lengthUnit);
                         break;
                     }
                 }
             }
         }
         return(inputUnit);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
 public MeasurementUnit(LengthUnit lengthUnit)
 {
     ConversionFactor = MeasurementUnitDictionary.ConversionToMM(lengthUnit);
     Name             = lengthUnit.ToString();
     LengthUnits      = lengthUnit;
 }