.Net 8 Blazor
Static Class, Static Fields
I am not sure what to call this issue, but I have a static read-only field where its value gets reflected as another value within the containing static class. I am not sure what would cause this or where to start looking. Any help would be appreciated.
See image of IntelliSense.
<code>public static class UnitOfMeasure
{
public static float MMToIn = (1 / 25.4F);
public static float inToMM = 25.4F;
public static readonly Unit Currency = new()
{
Name = "Currency",
DisplayName = "Currency",
Description = "Currency",
DefaultStep = .01F,
DefaultDecimalPlaces = CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit IN = new()
{
Name = "in",
DisplayName = "in",
Description = "inches",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MM = new()
{
Name = "mm",
DisplayName = "mm",
Description = "millimeter",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = MMToIn
};
public static readonly Unit SquareIN = new()
{
Name = "in²",
DisplayName = "in²",
Description = "inches squared",
DefaultStep = .001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "in²",
ConversionFactor = 1
};
public static readonly Unit SquareMM = new()
{
Name = "mm²",
DisplayName = "mm²",
Description = "inches squared",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mm²",
ConversionFactor = Pow(MMToIn, 2)
};
public static readonly Unit CubicIN = new()
{
Name = "in³",
DisplayName = "in³",
Description = "inches cubed",
DefaultStep = .001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "in³",
ConversionFactor = 1
};
public static readonly Unit CubicMM = new()
{
Name = "mm³",
DisplayName = "mm³",
Description = "inches cubed",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mm³",
ConversionFactor = Pow(MMToIn, 3)
};
public static readonly Unit L = new()
{
Name = "L",
DisplayName = "L",
Description = "Liters",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "L",
ConversionFactor = 1 / 0.01638706F
};
public static readonly Unit Gallon = new()
{
Name = "gal",
DisplayName = "gal",
Description = "Gallons",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "gal",
ConversionFactor = 1 / 0.004329F
};
public static readonly Unit ML = new()
{
Name = "ml",
DisplayName = "ml",
Description = "milliliters",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "ml",
ConversionFactor = 1 / 16.3871F
};
public static readonly Unit MG = new()
{
Name = "mg",
DisplayName = "mg",
Description = "milligrames",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "mg",
ConversionFactor = 1
};
public static readonly Unit G = new()
{
Name = "g",
DisplayName = "g",
Description = "grames",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "g",
ConversionFactor = 1000
};
public static readonly Unit KG = new()
{
Name = "kg",
DisplayName = "kg",
Description = "kilogrames",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "kg",
ConversionFactor = 1000000
};
public static readonly Unit DEG = new()
{
Name = "deg",
DisplayName = "deg",
Description = "degrees",
DefaultStep = 1,
DefaultDecimalPlaces = 1,
DrawingPostFix = "˚",
ConversionFactor = PI / 180
};
public static readonly Unit Percent = new()
{
Name = "%",
DisplayName = "%",
Description = "percent",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MGPerCubicIN = new()
{
Name = "mg/in³",
DisplayName = "mg/in³",
Description = "mg per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 0,
DrawingPostFix = "mg/in³",
ConversionFactor = 1
};
public static readonly Unit MGPerCubicMM = new()
{
Name = "mg/mm³",
DisplayName = "mg/mm³",
Description = "mg per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mg/mm³",
ConversionFactor = 1 / Pow(MMToIn, 3)
};
public static readonly Unit MGPerML = new()
{
Name = "mg/ml",
DisplayName = "mg/ml",
Description = "mg per milligrames",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mg/ml",
ConversionFactor = 1 * 16.3871F
};
public static readonly Unit GPerCubicIN = new()
{
Name = "g/in³",
DisplayName = "g/in³",
Description = "g per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "g/in³",
ConversionFactor = 1000
};
public static readonly Unit GPerCubicMM = new()
{
Name = "g/mm³",
DisplayName = "g/mm³",
Description = "g per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "g/mm³",
ConversionFactor = 1000 / Pow(MMToIn, 3)
};
public static readonly Unit GPerML = new()
{
Name = "g/ml",
DisplayName = "g/ml",
Description = "g per milligrames",
DefaultStep = .00001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "g/ml",
ConversionFactor = 1000 * 16.3871F
};
public static readonly Unit LBS = new()
{
Name = "LBS",
DisplayName = "LBS",
Description = "Pounds",
DefaultStep = 5,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Tons = new()
{
Name = "tons",
DisplayName = "tons",
Description = "Tons",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 2000
};
public static readonly Unit kN = new()
{
Name = "kN",
DisplayName = "kN",
Description = "kilonewton",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1 / 0.00444822F
};
public static readonly Unit kP = new()
{
Name = "kP",
DisplayName = "kP",
Description = "kilopond",
DefaultStep = 10,
DefaultDecimalPlaces = 1,
DrawingPostFix = "",
ConversionFactor = 2.2046226219F
};
public static readonly Unit MPA = new()
{
Name = "MPa",
DisplayName = "MPa",
Description = "Megapascal",
DefaultStep = 10,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 145
};
public static readonly Unit RPM = new()
{
Name = "RPM",
DisplayName = "RPM",
Description = "RPM",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Hertz = new()
{
Name = "Hz",
DisplayName = "Hz",
Description = "Hz",
DefaultStep = 1,
DefaultDecimalPlaces = 3,
DrawingPostFix = "",
ConversionFactor = 60.0F
};
public static readonly Unit TPM = new()
{
Name = "TPM",
DisplayName = "Tablets Per Minute",
Description = "Tablets Per Minute",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit TPH = new()
{
Name = "TPH",
DisplayName = "Tablets Per Hour",
Description = "Tablets Per Hour",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit HR = new()
{
Name = "hr",
DisplayName = "hr",
Description = "hours",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Tablets = new()
{
Name = "Tablets",
DisplayName = "Tablets",
Description = "Tablets",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit ToolStationQty = new()
{
Name = "ToolStationQty",
DisplayName = "Tool Station Qty",
Description = "Tool Station Qty",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MainCompressionRollerQty = new()
{
Name = "MainCompressionRollerQty",
DisplayName = "Main Compression Rollers",
Description = "Main Compression Rollers",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit TipQty = new()
{
Name = "TipQty",
DisplayName = "Tip Qty",
Description = "Tip Qty",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit ThickToWidthRatio = new()
{
Name = "ThickToWidthRatio",
DisplayName = "Thickness To Width",
Description = "Thickness To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit CornerRadiusToWidth = new()
{
Name = "CornerRadiusToWidth",
DisplayName = "Corner Radius To Width",
Description = "Corner Radius To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit CupToThickRatio = new()
{
Name = "CupToThickRatio",
DisplayName = "Cup To Thickness",
Description = "Cup To Thickness",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit LengthToWidthRatio = new()
{
Name = "LengthToWidthRatio",
DisplayName = "Length To Width",
Description = "Length To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit EndRadiusToWidthRatio = new()
{
Name = "EndRadiusToWidthRatio",
DisplayName = "End Radius To Width",
Description = "End Radius To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public class Unit
{
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public float DefaultStep { get; set; }
public int DefaultDecimalPlaces { get; set; }
public string DrawingPostFix { get; set; }
public float ConversionFactor { get; set; }
public bool ShowUOM { get; set; } = true;
public float Convert(Unit unitFrom, float value)
{
return (unitFrom.ConversionFactor / ConversionFactor) * value;
}
public static bool operator ==(Unit c1, Unit c2)
{
return c1?.Equals(c2) ?? false;
}
public static bool operator !=(Unit c1, Unit c2)
{
return !c1?.Equals(c2) ?? true;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
var objectToCompareWith = (Unit)obj;
return objectToCompareWith.Name == Name;
}
public override int GetHashCode()
{
return HashCode.Combine(Name);
}
}
}
</code>
<code>public static class UnitOfMeasure
{
public static float MMToIn = (1 / 25.4F);
public static float inToMM = 25.4F;
public static readonly Unit Currency = new()
{
Name = "Currency",
DisplayName = "Currency",
Description = "Currency",
DefaultStep = .01F,
DefaultDecimalPlaces = CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit IN = new()
{
Name = "in",
DisplayName = "in",
Description = "inches",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MM = new()
{
Name = "mm",
DisplayName = "mm",
Description = "millimeter",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = MMToIn
};
public static readonly Unit SquareIN = new()
{
Name = "in²",
DisplayName = "in²",
Description = "inches squared",
DefaultStep = .001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "in²",
ConversionFactor = 1
};
public static readonly Unit SquareMM = new()
{
Name = "mm²",
DisplayName = "mm²",
Description = "inches squared",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mm²",
ConversionFactor = Pow(MMToIn, 2)
};
public static readonly Unit CubicIN = new()
{
Name = "in³",
DisplayName = "in³",
Description = "inches cubed",
DefaultStep = .001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "in³",
ConversionFactor = 1
};
public static readonly Unit CubicMM = new()
{
Name = "mm³",
DisplayName = "mm³",
Description = "inches cubed",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mm³",
ConversionFactor = Pow(MMToIn, 3)
};
public static readonly Unit L = new()
{
Name = "L",
DisplayName = "L",
Description = "Liters",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "L",
ConversionFactor = 1 / 0.01638706F
};
public static readonly Unit Gallon = new()
{
Name = "gal",
DisplayName = "gal",
Description = "Gallons",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "gal",
ConversionFactor = 1 / 0.004329F
};
public static readonly Unit ML = new()
{
Name = "ml",
DisplayName = "ml",
Description = "milliliters",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "ml",
ConversionFactor = 1 / 16.3871F
};
public static readonly Unit MG = new()
{
Name = "mg",
DisplayName = "mg",
Description = "milligrames",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "mg",
ConversionFactor = 1
};
public static readonly Unit G = new()
{
Name = "g",
DisplayName = "g",
Description = "grames",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "g",
ConversionFactor = 1000
};
public static readonly Unit KG = new()
{
Name = "kg",
DisplayName = "kg",
Description = "kilogrames",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "kg",
ConversionFactor = 1000000
};
public static readonly Unit DEG = new()
{
Name = "deg",
DisplayName = "deg",
Description = "degrees",
DefaultStep = 1,
DefaultDecimalPlaces = 1,
DrawingPostFix = "˚",
ConversionFactor = PI / 180
};
public static readonly Unit Percent = new()
{
Name = "%",
DisplayName = "%",
Description = "percent",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MGPerCubicIN = new()
{
Name = "mg/in³",
DisplayName = "mg/in³",
Description = "mg per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 0,
DrawingPostFix = "mg/in³",
ConversionFactor = 1
};
public static readonly Unit MGPerCubicMM = new()
{
Name = "mg/mm³",
DisplayName = "mg/mm³",
Description = "mg per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mg/mm³",
ConversionFactor = 1 / Pow(MMToIn, 3)
};
public static readonly Unit MGPerML = new()
{
Name = "mg/ml",
DisplayName = "mg/ml",
Description = "mg per milligrames",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mg/ml",
ConversionFactor = 1 * 16.3871F
};
public static readonly Unit GPerCubicIN = new()
{
Name = "g/in³",
DisplayName = "g/in³",
Description = "g per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "g/in³",
ConversionFactor = 1000
};
public static readonly Unit GPerCubicMM = new()
{
Name = "g/mm³",
DisplayName = "g/mm³",
Description = "g per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "g/mm³",
ConversionFactor = 1000 / Pow(MMToIn, 3)
};
public static readonly Unit GPerML = new()
{
Name = "g/ml",
DisplayName = "g/ml",
Description = "g per milligrames",
DefaultStep = .00001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "g/ml",
ConversionFactor = 1000 * 16.3871F
};
public static readonly Unit LBS = new()
{
Name = "LBS",
DisplayName = "LBS",
Description = "Pounds",
DefaultStep = 5,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Tons = new()
{
Name = "tons",
DisplayName = "tons",
Description = "Tons",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 2000
};
public static readonly Unit kN = new()
{
Name = "kN",
DisplayName = "kN",
Description = "kilonewton",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1 / 0.00444822F
};
public static readonly Unit kP = new()
{
Name = "kP",
DisplayName = "kP",
Description = "kilopond",
DefaultStep = 10,
DefaultDecimalPlaces = 1,
DrawingPostFix = "",
ConversionFactor = 2.2046226219F
};
public static readonly Unit MPA = new()
{
Name = "MPa",
DisplayName = "MPa",
Description = "Megapascal",
DefaultStep = 10,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 145
};
public static readonly Unit RPM = new()
{
Name = "RPM",
DisplayName = "RPM",
Description = "RPM",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Hertz = new()
{
Name = "Hz",
DisplayName = "Hz",
Description = "Hz",
DefaultStep = 1,
DefaultDecimalPlaces = 3,
DrawingPostFix = "",
ConversionFactor = 60.0F
};
public static readonly Unit TPM = new()
{
Name = "TPM",
DisplayName = "Tablets Per Minute",
Description = "Tablets Per Minute",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit TPH = new()
{
Name = "TPH",
DisplayName = "Tablets Per Hour",
Description = "Tablets Per Hour",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit HR = new()
{
Name = "hr",
DisplayName = "hr",
Description = "hours",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Tablets = new()
{
Name = "Tablets",
DisplayName = "Tablets",
Description = "Tablets",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit ToolStationQty = new()
{
Name = "ToolStationQty",
DisplayName = "Tool Station Qty",
Description = "Tool Station Qty",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MainCompressionRollerQty = new()
{
Name = "MainCompressionRollerQty",
DisplayName = "Main Compression Rollers",
Description = "Main Compression Rollers",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit TipQty = new()
{
Name = "TipQty",
DisplayName = "Tip Qty",
Description = "Tip Qty",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit ThickToWidthRatio = new()
{
Name = "ThickToWidthRatio",
DisplayName = "Thickness To Width",
Description = "Thickness To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit CornerRadiusToWidth = new()
{
Name = "CornerRadiusToWidth",
DisplayName = "Corner Radius To Width",
Description = "Corner Radius To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit CupToThickRatio = new()
{
Name = "CupToThickRatio",
DisplayName = "Cup To Thickness",
Description = "Cup To Thickness",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit LengthToWidthRatio = new()
{
Name = "LengthToWidthRatio",
DisplayName = "Length To Width",
Description = "Length To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit EndRadiusToWidthRatio = new()
{
Name = "EndRadiusToWidthRatio",
DisplayName = "End Radius To Width",
Description = "End Radius To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public class Unit
{
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public float DefaultStep { get; set; }
public int DefaultDecimalPlaces { get; set; }
public string DrawingPostFix { get; set; }
public float ConversionFactor { get; set; }
public bool ShowUOM { get; set; } = true;
public float Convert(Unit unitFrom, float value)
{
return (unitFrom.ConversionFactor / ConversionFactor) * value;
}
public static bool operator ==(Unit c1, Unit c2)
{
return c1?.Equals(c2) ?? false;
}
public static bool operator !=(Unit c1, Unit c2)
{
return !c1?.Equals(c2) ?? true;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
var objectToCompareWith = (Unit)obj;
return objectToCompareWith.Name == Name;
}
public override int GetHashCode()
{
return HashCode.Combine(Name);
}
}
}
</code>
public static class UnitOfMeasure
{
public static float MMToIn = (1 / 25.4F);
public static float inToMM = 25.4F;
public static readonly Unit Currency = new()
{
Name = "Currency",
DisplayName = "Currency",
Description = "Currency",
DefaultStep = .01F,
DefaultDecimalPlaces = CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit IN = new()
{
Name = "in",
DisplayName = "in",
Description = "inches",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MM = new()
{
Name = "mm",
DisplayName = "mm",
Description = "millimeter",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = MMToIn
};
public static readonly Unit SquareIN = new()
{
Name = "in²",
DisplayName = "in²",
Description = "inches squared",
DefaultStep = .001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "in²",
ConversionFactor = 1
};
public static readonly Unit SquareMM = new()
{
Name = "mm²",
DisplayName = "mm²",
Description = "inches squared",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mm²",
ConversionFactor = Pow(MMToIn, 2)
};
public static readonly Unit CubicIN = new()
{
Name = "in³",
DisplayName = "in³",
Description = "inches cubed",
DefaultStep = .001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "in³",
ConversionFactor = 1
};
public static readonly Unit CubicMM = new()
{
Name = "mm³",
DisplayName = "mm³",
Description = "inches cubed",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mm³",
ConversionFactor = Pow(MMToIn, 3)
};
public static readonly Unit L = new()
{
Name = "L",
DisplayName = "L",
Description = "Liters",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "L",
ConversionFactor = 1 / 0.01638706F
};
public static readonly Unit Gallon = new()
{
Name = "gal",
DisplayName = "gal",
Description = "Gallons",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "gal",
ConversionFactor = 1 / 0.004329F
};
public static readonly Unit ML = new()
{
Name = "ml",
DisplayName = "ml",
Description = "milliliters",
DefaultStep = .01F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "ml",
ConversionFactor = 1 / 16.3871F
};
public static readonly Unit MG = new()
{
Name = "mg",
DisplayName = "mg",
Description = "milligrames",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "mg",
ConversionFactor = 1
};
public static readonly Unit G = new()
{
Name = "g",
DisplayName = "g",
Description = "grames",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "g",
ConversionFactor = 1000
};
public static readonly Unit KG = new()
{
Name = "kg",
DisplayName = "kg",
Description = "kilogrames",
DefaultStep = .001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "kg",
ConversionFactor = 1000000
};
public static readonly Unit DEG = new()
{
Name = "deg",
DisplayName = "deg",
Description = "degrees",
DefaultStep = 1,
DefaultDecimalPlaces = 1,
DrawingPostFix = "˚",
ConversionFactor = PI / 180
};
public static readonly Unit Percent = new()
{
Name = "%",
DisplayName = "%",
Description = "percent",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MGPerCubicIN = new()
{
Name = "mg/in³",
DisplayName = "mg/in³",
Description = "mg per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 0,
DrawingPostFix = "mg/in³",
ConversionFactor = 1
};
public static readonly Unit MGPerCubicMM = new()
{
Name = "mg/mm³",
DisplayName = "mg/mm³",
Description = "mg per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mg/mm³",
ConversionFactor = 1 / Pow(MMToIn, 3)
};
public static readonly Unit MGPerML = new()
{
Name = "mg/ml",
DisplayName = "mg/ml",
Description = "mg per milligrames",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "mg/ml",
ConversionFactor = 1 * 16.3871F
};
public static readonly Unit GPerCubicIN = new()
{
Name = "g/in³",
DisplayName = "g/in³",
Description = "g per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "g/in³",
ConversionFactor = 1000
};
public static readonly Unit GPerCubicMM = new()
{
Name = "g/mm³",
DisplayName = "g/mm³",
Description = "g per inches cubed",
DefaultStep = .00001F,
DefaultDecimalPlaces = 5,
DrawingPostFix = "g/mm³",
ConversionFactor = 1000 / Pow(MMToIn, 3)
};
public static readonly Unit GPerML = new()
{
Name = "g/ml",
DisplayName = "g/ml",
Description = "g per milligrames",
DefaultStep = .00001F,
DefaultDecimalPlaces = 4,
DrawingPostFix = "g/ml",
ConversionFactor = 1000 * 16.3871F
};
public static readonly Unit LBS = new()
{
Name = "LBS",
DisplayName = "LBS",
Description = "Pounds",
DefaultStep = 5,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Tons = new()
{
Name = "tons",
DisplayName = "tons",
Description = "Tons",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 2000
};
public static readonly Unit kN = new()
{
Name = "kN",
DisplayName = "kN",
Description = "kilonewton",
DefaultStep = .1F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1 / 0.00444822F
};
public static readonly Unit kP = new()
{
Name = "kP",
DisplayName = "kP",
Description = "kilopond",
DefaultStep = 10,
DefaultDecimalPlaces = 1,
DrawingPostFix = "",
ConversionFactor = 2.2046226219F
};
public static readonly Unit MPA = new()
{
Name = "MPa",
DisplayName = "MPa",
Description = "Megapascal",
DefaultStep = 10,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 145
};
public static readonly Unit RPM = new()
{
Name = "RPM",
DisplayName = "RPM",
Description = "RPM",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Hertz = new()
{
Name = "Hz",
DisplayName = "Hz",
Description = "Hz",
DefaultStep = 1,
DefaultDecimalPlaces = 3,
DrawingPostFix = "",
ConversionFactor = 60.0F
};
public static readonly Unit TPM = new()
{
Name = "TPM",
DisplayName = "Tablets Per Minute",
Description = "Tablets Per Minute",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit TPH = new()
{
Name = "TPH",
DisplayName = "Tablets Per Hour",
Description = "Tablets Per Hour",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit HR = new()
{
Name = "hr",
DisplayName = "hr",
Description = "hours",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit Tablets = new()
{
Name = "Tablets",
DisplayName = "Tablets",
Description = "Tablets",
DefaultStep = 1,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit ToolStationQty = new()
{
Name = "ToolStationQty",
DisplayName = "Tool Station Qty",
Description = "Tool Station Qty",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit MainCompressionRollerQty = new()
{
Name = "MainCompressionRollerQty",
DisplayName = "Main Compression Rollers",
Description = "Main Compression Rollers",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit TipQty = new()
{
Name = "TipQty",
DisplayName = "Tip Qty",
Description = "Tip Qty",
DefaultStep = 1,
DefaultDecimalPlaces = 0,
DrawingPostFix = "",
ConversionFactor = 1
};
public static readonly Unit ThickToWidthRatio = new()
{
Name = "ThickToWidthRatio",
DisplayName = "Thickness To Width",
Description = "Thickness To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit CornerRadiusToWidth = new()
{
Name = "CornerRadiusToWidth",
DisplayName = "Corner Radius To Width",
Description = "Corner Radius To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit CupToThickRatio = new()
{
Name = "CupToThickRatio",
DisplayName = "Cup To Thickness",
Description = "Cup To Thickness",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit LengthToWidthRatio = new()
{
Name = "LengthToWidthRatio",
DisplayName = "Length To Width",
Description = "Length To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public static readonly Unit EndRadiusToWidthRatio = new()
{
Name = "EndRadiusToWidthRatio",
DisplayName = "End Radius To Width",
Description = "End Radius To Width",
DefaultStep = .01F,
DefaultDecimalPlaces = 2,
DrawingPostFix = "",
ConversionFactor = 1,
ShowUOM = false
};
public class Unit
{
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public float DefaultStep { get; set; }
public int DefaultDecimalPlaces { get; set; }
public string DrawingPostFix { get; set; }
public float ConversionFactor { get; set; }
public bool ShowUOM { get; set; } = true;
public float Convert(Unit unitFrom, float value)
{
return (unitFrom.ConversionFactor / ConversionFactor) * value;
}
public static bool operator ==(Unit c1, Unit c2)
{
return c1?.Equals(c2) ?? false;
}
public static bool operator !=(Unit c1, Unit c2)
{
return !c1?.Equals(c2) ?? true;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
var objectToCompareWith = (Unit)obj;
return objectToCompareWith.Name == Name;
}
public override int GetHashCode()
{
return HashCode.Combine(Name);
}
}
}
Static Read-Only Fields never change values