diff --git a/Gu.Units.Generator.Tests/MockSettings.cs b/Gu.Units.Generator.Tests/MockSettings.cs index daa75529..29740610 100644 --- a/Gu.Units.Generator.Tests/MockSettings.cs +++ b/Gu.Units.Generator.Tests/MockSettings.cs @@ -2,7 +2,6 @@ { public class MockSettings : Settings { - public readonly string Namespace = "Gu.Units"; public readonly SiUnit Metres; public readonly Quantity Length; @@ -32,7 +31,7 @@ public class MockSettings : Settings public readonly DerivedUnit Watts; public readonly Quantity Power; - + public readonly DerivedUnit Volts; public readonly Quantity Voltage; @@ -41,23 +40,23 @@ public class MockSettings : Settings public MockSettings() { - Metres = new SiUnit(Namespace, "Metres", "m") { QuantityName = "Length" }; + Metres = new SiUnit("Metres", "m") { QuantityName = "Length" }; SiUnits.Add(Metres); Length = Metres.Quantity; - Seconds = new SiUnit(Namespace, "Seconds", "s") { QuantityName = "Time" }; + Seconds = new SiUnit("Seconds", "s") { QuantityName = "Time" }; SiUnits.Add(Seconds); Time = Seconds.Quantity; - Kilograms = new SiUnit("", "Kilograms", "kg") { QuantityName = "Mass" }; + Kilograms = new SiUnit("Kilograms", "kg") { QuantityName = "Mass" }; SiUnits.Add(Kilograms); Mass = Kilograms.Quantity; - Amperes = new SiUnit("", "Amperes", "A") { QuantityName = "ElectricalCurrent" }; + Amperes = new SiUnit("Amperes", "A") { QuantityName = "ElectricalCurrent" }; SiUnits.Add(Amperes); Current = Amperes.Quantity; - MetresPerSecond = new DerivedUnit(Namespace, + MetresPerSecond = new DerivedUnit( "MetresPerSecond", "m/s", new UnitAndPower(Metres, 1), @@ -65,7 +64,7 @@ public MockSettings() DerivedUnits.Add(MetresPerSecond); Speed = MetresPerSecond.Quantity; - Newtons = new DerivedUnit(Namespace, + Newtons = new DerivedUnit( "Newtons", "N", new UnitAndPower(Kilograms, 1), @@ -74,7 +73,7 @@ public MockSettings() DerivedUnits.Add(Newtons); Force = Newtons.Quantity; - Joules = new DerivedUnit(Namespace, + Joules = new DerivedUnit( "Joules", "J", new UnitAndPower(Newtons, 1), @@ -82,7 +81,7 @@ public MockSettings() DerivedUnits.Add(Joules); Energy = Joules.Quantity; - Watts = new DerivedUnit(Namespace, + Watts = new DerivedUnit( "Watts", "W", new UnitAndPower(Joules, 1), @@ -90,7 +89,7 @@ public MockSettings() DerivedUnits.Add(Watts); Power = Watts.Quantity; - Volts = new DerivedUnit(Namespace, + Volts = new DerivedUnit( "Volts", "V", new UnitAndPower(Watts, 1), @@ -98,7 +97,7 @@ public MockSettings() DerivedUnits.Add(Volts); Voltage = Volts.Quantity; - Coloumbs = new DerivedUnit(Namespace, + Coloumbs = new DerivedUnit( "Coloumbs", "C", new UnitAndPower(Seconds, 1), @@ -106,14 +105,14 @@ public MockSettings() DerivedUnits.Add(Coloumbs); ElectricCharge = Coloumbs.Quantity; - SquareMetres = new DerivedUnit(Namespace, "SquareMetres", "m^2", new UnitAndPower(Metres, 2)) + SquareMetres = new DerivedUnit("SquareMetres", "m^2", new UnitAndPower(Metres, 2)) { QuantityName = "Area" }; DerivedUnits.Add(SquareMetres); Area = SquareMetres.Quantity; - CubicMetres = new DerivedUnit(Namespace, "CubicMetres", "m^3", new UnitAndPower(Metres, 3)) + CubicMetres = new DerivedUnit("CubicMetres", "m^3", new UnitAndPower(Metres, 3)) { QuantityName = "Volume" }; diff --git a/Gu.Units.Generator.Tests/QuantityTests.cs b/Gu.Units.Generator.Tests/QuantityTests.cs index 78efa315..13398643 100644 --- a/Gu.Units.Generator.Tests/QuantityTests.cs +++ b/Gu.Units.Generator.Tests/QuantityTests.cs @@ -7,7 +7,6 @@ public class QuantityTests { private IUnit _metres; - private string Namespace; private IUnit _seconds; private MockSettings _settings; [SetUp] @@ -16,7 +15,6 @@ public void SetUp() _settings = new MockSettings(); _metres = _settings.Metres; _seconds = _settings.Seconds; - Namespace = _settings.Namespace; } [TestCase("Length", "IQuantity")] @@ -33,7 +31,7 @@ public void BaseQuantityInterface(string quantityName, string expected) public void PowerQuantityInterface(int power, string expected) { var unitAndPower = new UnitAndPower(_metres, power); - var derivedUnit = new DerivedUnit(Namespace, "sdf", "ssf", unitAndPower) { QuantityName = "Qty" }; + var derivedUnit = new DerivedUnit("sdf", "ssf", unitAndPower) { QuantityName = "Qty" }; var quantity = new Quantity(derivedUnit); var @interface = quantity.Interface; Assert.AreEqual(expected, @interface); @@ -46,8 +44,8 @@ public void ComposedQuantityInterface(int p1, int p2, string expected) var unitAndPower2 = new UnitAndPower(_seconds, p2); var quantities = new[] { - new Quantity(new DerivedUnit("", "", "", unitAndPower1, unitAndPower2)), - new Quantity(new DerivedUnit("", "", "", unitAndPower2, unitAndPower1)) + new Quantity(new DerivedUnit("", "", unitAndPower1, unitAndPower2)), + new Quantity(new DerivedUnit("", "", unitAndPower2, unitAndPower1)) }; foreach (var quantity in quantities) { diff --git a/Gu.Units.Generator/Descriptors/Conversion.cs b/Gu.Units.Generator/Descriptors/Conversion.cs index 8a656962..fe9cc65f 100644 --- a/Gu.Units.Generator/Descriptors/Conversion.cs +++ b/Gu.Units.Generator/Descriptors/Conversion.cs @@ -22,8 +22,8 @@ public Conversion() _formula = new ConversionFormula(this); } - public Conversion(string @namespace, string className, string symbol) - : base(@namespace, className) + public Conversion(string className, string symbol) + : base(className) { _symbol = symbol; _formula = new ConversionFormula(this); @@ -46,23 +46,6 @@ public string Symbol } } - public double ConversionFactor - { - get - { - return _formula.ConversionFactor; - } - set - { - if (value == _formula.ConversionFactor) - { - return; - } - _formula.ConversionFactor = value; - this.OnPropertyChanged(); - } - } - public ConversionFormula Formula { get { return _formula; } @@ -150,6 +133,7 @@ public ObservableCollection Conversions { get { return _conversions; } } + public bool AnyOffsetConversion { get { return Conversions.Any(x => x.Formula.Offset != 0); } @@ -172,7 +156,7 @@ private void SyncWithPrefix() { return; } - ConversionFactor = Math.Pow(10, _prefix.Power); + Formula.ConversionFactor = Math.Pow(10, _prefix.Power); if (string.IsNullOrEmpty(Symbol)) { Symbol = Prefix.Symbol + BaseUnit.Symbol; @@ -195,10 +179,10 @@ public void SetParts(IEnumerable subunits) foreach (var part in subunits) { var up = unitParts.Single(x => x.UnitName == part.BaseUnit.ClassName); - cf = cf * Math.Pow(part.ConversionFactor, up.Power); + cf = cf * Math.Pow(part.Formula.ConversionFactor, up.Power); unitParts.Replace(up, new UnitAndPower(part, up.Power)); } - ConversionFactor = cf; + Formula.ConversionFactor = cf; ClassName = unitParts.UnitName; Symbol = unitParts.Expression; } diff --git a/Gu.Units.Generator/Descriptors/DerivedUnit.cs b/Gu.Units.Generator/Descriptors/DerivedUnit.cs index a103035d..4391c42f 100644 --- a/Gu.Units.Generator/Descriptors/DerivedUnit.cs +++ b/Gu.Units.Generator/Descriptors/DerivedUnit.cs @@ -15,13 +15,13 @@ public class DerivedUnit : UnitBase private readonly UnitParts _parts; public DerivedUnit() - : base(null, null, null) + : base(null, null) { _parts = new UnitParts(this); } - public DerivedUnit(string @namespace, string name, string symbol, params UnitAndPower[] parts) - : base(@namespace, name, symbol) + public DerivedUnit(string name, string symbol, params UnitAndPower[] parts) + : base(name, symbol) { _parts = new UnitParts(this); if (parts.Length == 0) diff --git a/Gu.Units.Generator/Descriptors/IUnit.cs b/Gu.Units.Generator/Descriptors/IUnit.cs index e26d639b..ed503b6b 100644 --- a/Gu.Units.Generator/Descriptors/IUnit.cs +++ b/Gu.Units.Generator/Descriptors/IUnit.cs @@ -7,7 +7,6 @@ public interface IUnit : INotifyPropertyChanged { string Symbol { get; set; } string ClassName { get; set; } - string Namespace { get; set; } string ParameterName { get; } string QuantityName { get; set; } Quantity Quantity { get; set; } diff --git a/Gu.Units.Generator/Descriptors/Quantity.cs b/Gu.Units.Generator/Descriptors/Quantity.cs index a0a83169..38317a0d 100644 --- a/Gu.Units.Generator/Descriptors/Quantity.cs +++ b/Gu.Units.Generator/Descriptors/Quantity.cs @@ -14,7 +14,7 @@ public class Quantity : TypeMetaData private string _unitName; public Quantity(IUnit unit) - : base(unit.Namespace, null) + : base(null) { _unit = unit; _unit.Quantity = this; diff --git a/Gu.Units.Generator/Descriptors/SiUnit.cs b/Gu.Units.Generator/Descriptors/SiUnit.cs index 8ed68851..43933c10 100644 --- a/Gu.Units.Generator/Descriptors/SiUnit.cs +++ b/Gu.Units.Generator/Descriptors/SiUnit.cs @@ -16,12 +16,12 @@ public class SiUnit : UnitBase { public SiUnit() - : base(null, null, null) + : base(null, null) { } - public SiUnit(string @namespace, string name, string symbol) - : base(@namespace, name, symbol) + public SiUnit(string name, string symbol) + : base(name, symbol) { } diff --git a/Gu.Units.Generator/Descriptors/TypeMetaData.cs b/Gu.Units.Generator/Descriptors/TypeMetaData.cs index f1276166..0256a0ff 100644 --- a/Gu.Units.Generator/Descriptors/TypeMetaData.cs +++ b/Gu.Units.Generator/Descriptors/TypeMetaData.cs @@ -12,36 +12,18 @@ public class TypeMetaData : MarshalByRefObject, INotifyPropertyChanged { private string _className; - private string _ns; protected TypeMetaData() { } - public TypeMetaData(string @namespace,string className) + public TypeMetaData(string className) { - _ns = @namespace; _className = className; } public event PropertyChangedEventHandler PropertyChanged; - public virtual string Namespace - { - get { return _ns; } - set - { - if (value == _ns) - { - return; - } - _ns = value; - OnPropertyChanged(); - } - } - - public string Ns { get; set; } - public string ClassName { get { return _className; } diff --git a/Gu.Units.Generator/Descriptors/UnitBase.cs b/Gu.Units.Generator/Descriptors/UnitBase.cs index 380a82a9..f8142496 100644 --- a/Gu.Units.Generator/Descriptors/UnitBase.cs +++ b/Gu.Units.Generator/Descriptors/UnitBase.cs @@ -21,8 +21,8 @@ protected UnitBase() Quantity = new Quantity(this); } - protected UnitBase(string @namespace, string className, string symbol) - : base(@namespace, className) + protected UnitBase(string className, string symbol) + : base(className) { _conversions = new ParentCollection(this, (unit, parent) => unit.BaseUnit = parent); Quantity = new Quantity(this); diff --git a/Gu.Units.Generator/GeneratorSettings.xml b/Gu.Units.Generator/GeneratorSettings.xml index f28db2c3..3f2432ee 100644 --- a/Gu.Units.Generator/GeneratorSettings.xml +++ b/Gu.Units.Generator/GeneratorSettings.xml @@ -2,7 +2,6 @@ - Gu.Units SquareMetres Area @@ -10,7 +9,6 @@ SquareMillimetres mm² - 1E-06 1E-06 0 @@ -20,7 +18,6 @@ SquareCentimetres cm² - 0.0001 0.0001 0 @@ -30,7 +27,6 @@ SquareDecimetres dm² - 0.010000000000000002 0.010000000000000002 0 @@ -40,7 +36,6 @@ SquareKilometres km² - 1000000 1000000 0 @@ -50,7 +45,6 @@ SquareInches in² - 0.00064516 0.00064516 0 @@ -60,7 +54,6 @@ Hectare ha - 10000 10000 0 @@ -70,7 +63,6 @@ SquareMile mi² - 2589988.110336 2589988.110336 0 @@ -80,7 +72,6 @@ SquareYard yd² - 0.83612736 0.83612736 0 @@ -96,7 +87,6 @@ - Gu.Units CubicMetres Volume @@ -104,7 +94,6 @@ Litres L - 0.0010000000000000002 0.0010000000000000002 0 @@ -114,7 +103,6 @@ CubicCentimetres cm³ - 1.0000000000000002E-06 1.0000000000000002E-06 0 @@ -124,7 +112,6 @@ CubicMillimetres mm³ - 1E-09 1E-09 0 @@ -134,7 +121,6 @@ CubicInches in³ - 1.6387064E-05 1.6387064E-05 0 @@ -150,7 +136,6 @@ - Gu.Units Newtons N Force @@ -158,7 +143,6 @@ Nanonewtons nN - 1E-09 1E-09 0 @@ -168,7 +152,6 @@ Micronewtons µN - 1E-06 1E-06 0 @@ -178,7 +161,6 @@ Millinewtons mN - 0.001 0.001 0 @@ -188,7 +170,6 @@ Kilonewtons kN - 1000 1000 0 @@ -198,7 +179,6 @@ Meganewtons MN - 1000000 1000000 0 @@ -208,7 +188,6 @@ Giganewtons GN - 1000000000 1000000000 0 @@ -232,7 +211,6 @@ - Gu.Units Pascals Pa Pressure @@ -240,7 +218,6 @@ Nanopascals nPa - 1E-09 1E-09 0 @@ -250,7 +227,6 @@ Micropascals µPa - 1E-06 1E-06 0 @@ -260,7 +236,6 @@ Millipascals mPa - 0.001 0.001 0 @@ -270,7 +245,6 @@ Kilopascals kPa - 1000 1000 0 @@ -280,7 +254,6 @@ Megapascals MPa - 1000000 1000000 0 @@ -290,7 +263,6 @@ Gigapascals GPa - 1000000000 1000000000 0 @@ -310,7 +282,6 @@ - Gu.Units KilogramsPerCubicMetre kg/m³ Density @@ -318,7 +289,6 @@ GramsPerCubicMillimetre g / mm³ - 999999.99999999988 999999.99999999988 0 @@ -328,7 +298,6 @@ GramsPerCubicCentimetre g / cm³ - 999.99999999999989 999.99999999999989 0 @@ -348,7 +317,6 @@ - Gu.Units Joules J Energy @@ -356,7 +324,6 @@ Nanojoules nJ - 1E-09 1E-09 0 @@ -366,7 +333,6 @@ Microjoules µJ - 1E-06 1E-06 0 @@ -376,7 +342,6 @@ Millijoules mJ - 0.001 0.001 0 @@ -386,7 +351,6 @@ Kilojoules kJ - 1000 1000 0 @@ -396,7 +360,6 @@ Megajoules MJ - 1000000 1000000 0 @@ -406,7 +369,6 @@ Gigajoules GJ - 1000000000 1000000000 0 @@ -416,7 +378,6 @@ KilowattHours kWh - 3600000 3600000 0 @@ -440,7 +401,6 @@ - Gu.Units Watts W Power @@ -448,7 +408,6 @@ Nanowatts nW - 1E-09 1E-09 0 @@ -458,7 +417,6 @@ Microwatts µW - 1E-06 1E-06 0 @@ -468,7 +426,6 @@ Milliwatts mW - 0.001 0.001 0 @@ -478,7 +435,6 @@ Kilowatts kW - 1000 1000 0 @@ -488,7 +444,6 @@ Megawatts MW - 1000000 1000000 0 @@ -498,7 +453,6 @@ Gigawatts GW - 1000000000 1000000000 0 @@ -518,7 +472,6 @@ - Gu.Units MetresPerSecond m/s Speed @@ -526,7 +479,6 @@ MillimetresPerSecond mm / s - 0.001 0.001 0 @@ -536,7 +488,6 @@ CentimetresPerSecond cm / s - 0.01 0.01 0 @@ -546,7 +497,6 @@ KilometresPerHour km / h - 0.27777777777777779 0.27777777777777779 0 @@ -556,7 +506,6 @@ CentimetresPerMinute cm / min - 0.00016666666666666666 0.00016666666666666666 0 @@ -566,7 +515,6 @@ MetresPerMinute m / min - 0.016666666666666666 0.016666666666666666 0 @@ -576,7 +524,6 @@ MetresPerHour m / h - 0.00027777777777777778 0.00027777777777777778 0 @@ -586,7 +533,6 @@ MillimetresPerHour mm / h - 2.7777777777777776E-07 2.7777777777777776E-07 0 @@ -596,7 +542,6 @@ CentimetresPerHour cm / h - 2.7777777777777779E-06 2.7777777777777779E-06 0 @@ -606,7 +551,6 @@ MillimetresPerMinute mm / min - 1.6666666666666667E-05 1.6666666666666667E-05 0 @@ -626,7 +570,6 @@ - Gu.Units RadiansPerSecond rad/s AngularSpeed @@ -634,7 +577,6 @@ RevolutionsPerMinute rpm - 0.10471975511966 0.10471975511966 0 @@ -654,7 +596,6 @@ - Gu.Units Hertz Hz Frequency @@ -662,7 +603,6 @@ Millihertz mHz - 0.001 0.001 0 @@ -672,7 +612,6 @@ Kilohertz kHz - 1000 1000 0 @@ -682,7 +621,6 @@ Megahertz MHz - 1000000 1000000 0 @@ -692,7 +630,6 @@ Gigahertz GHz - 1000000000 1000000000 0 @@ -708,7 +645,6 @@ - Gu.Units MetresPerSecondSquared m/s² Acceleration @@ -716,7 +652,6 @@ MillimetresPerSecondSquared mm / s^2 - 1E-06 1E-06 0 @@ -726,7 +661,6 @@ CentimetresPerSecondSquared cm / s^2 - 0.0001 0.0001 0 @@ -746,7 +680,6 @@ - Gu.Units NewtonMetres N⋅m Torque @@ -767,7 +700,6 @@ - Gu.Units NewtonsPerMetre N/m Stiffness @@ -784,7 +716,6 @@ - Gu.Units CubicMetresPerSecond m³ / s VolumetricFlow @@ -801,7 +732,6 @@ - Gu.Units Volts V Voltage @@ -809,7 +739,6 @@ Millivolts mV - 0.001 0.001 0 @@ -819,7 +748,6 @@ Kilovolts kV - 1000 1000 0 @@ -829,7 +757,6 @@ Megavolts MV - 1000000 1000000 0 @@ -839,7 +766,6 @@ Microvolts µV - 1E-06 1E-06 0 @@ -859,7 +785,6 @@ - Gu.Units Ohm Ω Resistance @@ -867,7 +792,6 @@ Microohm µΩ - 1E-06 1E-06 0 @@ -877,7 +801,6 @@ Milliohm - 0.001 0.001 0 @@ -887,7 +810,6 @@ Kiloohm - 1000 1000 0 @@ -897,7 +819,6 @@ Megaohm - 1000000 1000000 0 @@ -987,7 +908,6 @@ - Gu.Units Kilograms kg Mass @@ -995,7 +915,6 @@ Grams g - 0.001 0.001 0 @@ -1005,7 +924,6 @@ Milligrams mg - 1E-06 1E-06 0 @@ -1015,7 +933,6 @@ Micrograms µg - 1E-09 1E-09 0 @@ -1025,7 +942,6 @@ - Gu.Units Metres m Length @@ -1033,7 +949,6 @@ Nanometres nm - 1E-09 1E-09 0 @@ -1043,7 +958,6 @@ Micrometres µm - 1E-06 1E-06 0 @@ -1053,7 +967,6 @@ Millimetres mm - 0.001 0.001 0 @@ -1063,7 +976,6 @@ Centimetres cm - 0.01 0.01 0 @@ -1073,7 +985,6 @@ Decimetres dm - 0.1 0.1 0 @@ -1083,7 +994,6 @@ Kilometres km - 1000 1000 0 @@ -1093,7 +1003,6 @@ Inches in - 0.0254 0.0254 0 @@ -1103,7 +1012,6 @@ Mile mi - 1609.344 1609.344 0 @@ -1113,7 +1021,6 @@ Yard yd - 0.9144 0.9144 0 @@ -1123,7 +1030,6 @@ NauticalMile nmi - 1852 1852 0 @@ -1133,7 +1039,6 @@ - Gu.Units Seconds s Time @@ -1141,7 +1046,6 @@ Nanoseconds ns - 1E-09 1E-09 0 @@ -1151,7 +1055,6 @@ Microseconds µs - 1E-06 1E-06 0 @@ -1161,7 +1064,6 @@ Milliseconds ms - 0.001 0.001 0 @@ -1171,7 +1073,6 @@ Hours h - 3600 3600 0 @@ -1181,7 +1082,6 @@ Minutes min - 60 60 0 @@ -1191,7 +1091,6 @@ - Gu.Units Kelvin K Temperature @@ -1199,7 +1098,6 @@ Celsius °C - 1 1 -273.15 @@ -1209,7 +1107,6 @@ Fahrenheit °F - 1.8 1.8 -459.67 @@ -1219,7 +1116,6 @@ - Gu.Units Radians rad Angle @@ -1227,7 +1123,6 @@ Degrees ° - 57.295779513082323 57.295779513082323 0 @@ -1237,7 +1132,6 @@ - Gu.Units Fractions /x Fraction @@ -1245,7 +1139,6 @@ PartsPerMillion ppm - 1E-06 1E-06 0 @@ -1255,7 +1148,6 @@ Promilles - 0.001 0.001 0 @@ -1265,7 +1157,6 @@ Percents % - 0.01 0.01 0 @@ -1275,7 +1166,6 @@ - Gu.Units Amperes A Current @@ -1283,7 +1173,6 @@ Milliamperes mA - 0.001 0.001 0 @@ -1293,7 +1182,6 @@ Kiloamperes kA - 1000 1000 0 @@ -1303,7 +1191,6 @@ Megaamperes MA - 1000000 1000000 0 @@ -1313,7 +1200,6 @@ Microamperes µA - 1E-06 1E-06 0 diff --git a/Gu.Units.Generator/MainWindow.xaml b/Gu.Units.Generator/MainWindow.xaml index da75ddb4..42058c56 100644 --- a/Gu.Units.Generator/MainWindow.xaml +++ b/Gu.Units.Generator/MainWindow.xaml @@ -150,7 +150,6 @@ - diff --git a/Gu.Units.Generator/PartConversionVm.cs b/Gu.Units.Generator/PartConversionVm.cs index 88f47f8a..dfc1c0ec 100644 --- a/Gu.Units.Generator/PartConversionVm.cs +++ b/Gu.Units.Generator/PartConversionVm.cs @@ -26,7 +26,7 @@ public bool IsUsed { get { - return _unit.Conversions.Any(x => x.ConversionFactor == Temp.ConversionFactor); + return _unit.Conversions.Any(x => x.Formula.ConversionFactor == Temp.Formula.ConversionFactor); } set { @@ -42,7 +42,7 @@ public bool IsUsed } else { - _unit.Conversions.InvokeRemove(x => x.ConversionFactor == Temp.ConversionFactor); + _unit.Conversions.InvokeRemove(x => x.Formula.ConversionFactor == Temp.Formula.ConversionFactor); } OnPropertyChanged(); } diff --git a/Gu.Units.Generator/PrefixConversionVm.cs b/Gu.Units.Generator/PrefixConversionVm.cs index 66959356..e13d3d7b 100644 --- a/Gu.Units.Generator/PrefixConversionVm.cs +++ b/Gu.Units.Generator/PrefixConversionVm.cs @@ -34,7 +34,7 @@ public bool IsUsed { return false; } - return _unit.Conversions.Any(x => x.ConversionFactor == _temp.ConversionFactor && x.Symbol == _temp.Symbol); + return _unit.Conversions.Any(x => x.Formula.ConversionFactor == _temp.Formula.ConversionFactor && x.Symbol == _temp.Symbol); } set { diff --git a/Gu.Units.Generator/Templates/Quantity.tt b/Gu.Units.Generator/Templates/Quantity.tt index e43e7f07..e543ad2e 100644 --- a/Gu.Units.Generator/Templates/Quantity.tt +++ b/Gu.Units.Generator/Templates/Quantity.tt @@ -12,12 +12,12 @@ if(QuantityMetaData != null) } else { - var unit = new SiUnit("Gu.Units", "Metres", "m") + var unit = new SiUnit("Metres", "m") { QuantityName = "Length" }; - unit.Conversions.Add(new Conversion("Gu.Units", "Centimetres", "cm")); - unit.Conversions.Add(new Conversion("Gu.Units", "Millimetres", "mm")); + unit.Conversions.Add(new Conversion("Centimetres", "cm")); + unit.Conversions.Add(new Conversion("Millimetres", "mm")); quantity = unit.Quantity; } #> diff --git a/Gu.Units.Generator/Templates/Unit.tt b/Gu.Units.Generator/Templates/Unit.tt index 3f6ec7c6..fd320ac6 100644 --- a/Gu.Units.Generator/Templates/Unit.tt +++ b/Gu.Units.Generator/Templates/Unit.tt @@ -12,12 +12,12 @@ if(UnitMetaData != null) } else { - unit = new SiUnit("Gu.Units", "Metres", "m") + unit = new SiUnit("Metres", "m") { QuantityName = "Length" }; - unit.Conversions.Add(new Conversion("Gu.Units", "Centimetres", "cm")); - unit.Conversions.Add(new Conversion("Gu.Units", "Millimetres", "mm")); + unit.Conversions.Add(new Conversion("Centimetres", "cm")); + unit.Conversions.Add(new Conversion("Millimetres", "mm")); } #> namespace <#= Settings.Namespace #> @@ -72,13 +72,13 @@ namespace <#= Settings.Namespace #> if (unit.AnyOffsetConversion) { #> - public static readonly <#= unit.QuantityName #>Unit <#= su.ClassName #> = new <#= unit.QuantityName #>Unit(<#= su.ConversionFactor #>, <#= su.Formula.Offset #>, "<#= su.Symbol #>"); + public static readonly <#= unit.QuantityName #>Unit <#= su.ClassName #> = new <#= unit.QuantityName #>Unit(<#= su.Formula.ConversionFactor #>, <#= su.Formula.Offset #>, "<#= su.Symbol #>"); <# } else { #> - public static readonly <#= unit.QuantityName #>Unit <#= su.ClassName #> = new <#= unit.QuantityName #>Unit(<#= su.ConversionFactor #>, "<#= su.Symbol #>"); + public static readonly <#= unit.QuantityName #>Unit <#= su.ClassName #> = new <#= unit.QuantityName #>Unit(<#= su.Formula.ConversionFactor #>, "<#= su.Symbol #>"); <# } #><# diff --git a/Gu.Units.Generator/WpfStuff/TypeMetaDataConverter.cs b/Gu.Units.Generator/WpfStuff/TypeMetaDataConverter.cs index 6cf2a77a..a20bd25c 100644 --- a/Gu.Units.Generator/WpfStuff/TypeMetaDataConverter.cs +++ b/Gu.Units.Generator/WpfStuff/TypeMetaDataConverter.cs @@ -18,7 +18,7 @@ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinati public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { - return value == null ? null : new TypeMetaData("", (string)value); + return value == null ? null : new TypeMetaData((string)value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)