public void VerifyThatRdlShortnameIsUpdated() { var vm = new UnitPrefixBrowserViewModel(this.session.Object, this.siteDirectory, null, null, null, null); var sRdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); sRdl.Container = this.siteDirectory; var cat = new UnitPrefix(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "cat1", ShortName = "1", Container = sRdl }; var cat2 = new UnitPrefix(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "cat2", ShortName = "2", Container = sRdl }; CDPMessageBus.Current.SendObjectChangeEvent(cat, EventKind.Added); CDPMessageBus.Current.SendObjectChangeEvent(cat2, EventKind.Added); var rev = typeof(Thing).GetProperty("RevisionNumber"); rev.SetValue(sRdl, 3); sRdl.ShortName = "test"; CDPMessageBus.Current.SendObjectChangeEvent(sRdl, EventKind.Updated); Assert.IsTrue(vm.UnitPrefixes.Count(x => x.ContainerRdl == "test") == 2); }
/// <summary> /// Converts the base quantity to specified quantity. /// </summary> /// <param name="quantity">The base quantity.</param> /// <param name="prefix">The required quantity prefix.</param> public static double FromBase(double quantity, UnitPrefix prefix) { switch (prefix) { case UnitPrefix.None: return(quantity); case UnitPrefix.Atto: return(quantity * 1e18); case UnitPrefix.Femto: return(quantity * 1e15); case UnitPrefix.Piko: return(quantity * 1e12); case UnitPrefix.Nano: return(quantity * 1e9); case UnitPrefix.Mikro: return(quantity * 1e6); case UnitPrefix.Milli: return(quantity * 1e3); case UnitPrefix.Kilo: return(quantity * 1e-3); case UnitPrefix.Mega: return(quantity * 1e-6); case UnitPrefix.Giga: return(quantity * 1e-9); case UnitPrefix.Tera: return(quantity * 1e-12); case UnitPrefix.Peta: return(quantity * 1e-15); case UnitPrefix.Exa: return(quantity * 1e-18); default: return(quantity); } }
protected UnitName <S, T> GetUnitName(string data) { UnitPrefix <S, T> prefix = null; UnitBaseName <S, T> baseName = null; for (int index = 0; index < data.Length; index++) { var stringPrefix = data.Substring(0, index); var stringSuffix = data.Substring(index, data.Length - index); try { prefix = ConstantProvider.GetPrefixBySymbol(stringPrefix); baseName = ConstantProvider.GetUnitBySymbol(stringSuffix); if (prefix != null && baseName != null) { break; } } catch (UnitNotFoundException) { } } if (prefix == null || baseName == null) { throw new UnitParserException(string.Format("Can't find any prefix+unit called [{0}].", data)); } return(new UnitName <S, T>(prefix, baseName: baseName)); }
internal static double GetDoubleValue(this UnitPrefix prefix) { return(prefix switch { UnitPrefix.Yocto => 1e-24, UnitPrefix.Zepto => 1e-21, UnitPrefix.Atto => 1e-18, UnitPrefix.Femto => 1e-15, UnitPrefix.Pico => 1e-12, UnitPrefix.Nano => 1e-9, UnitPrefix.Micro => 1e-6, UnitPrefix.Milli => 1e-3, UnitPrefix.Centi => 1e-2, UnitPrefix.Deci => 1e-1, UnitPrefix.Unity => 1, UnitPrefix.Deca => 1e1, UnitPrefix.Hecto => 1e2, UnitPrefix.Kilo => 1e3, UnitPrefix.Mega => 1e6, UnitPrefix.Giga => 1e9, UnitPrefix.Tera => 1e12, UnitPrefix.Peta => 1e15, UnitPrefix.Exa => 1e18, UnitPrefix.Zetta => 1e21, UnitPrefix.Yotta => 1e24, _ => 1, });
public void VerifyThatUnitPrefixFromExistingRdlsAreLoaded() { var siterefenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null); var unitPrefix1 = new UnitPrefix(Guid.NewGuid(), null, null); var unitPrefix2 = new UnitPrefix(Guid.NewGuid(), null, null); siterefenceDataLibrary.UnitPrefix.Add(unitPrefix1); siterefenceDataLibrary.UnitPrefix.Add(unitPrefix2); this.siteDirectory.SiteReferenceDataLibrary.Add(siterefenceDataLibrary); var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, null); var modelReferenceDataLibrary = new ModelReferenceDataLibrary(Guid.NewGuid(), null, null); var unitPrefix3 = new UnitPrefix(Guid.NewGuid(), null, null); var unitPrefix4 = new UnitPrefix(Guid.NewGuid(), null, null); modelReferenceDataLibrary.UnitPrefix.Add(unitPrefix3); modelReferenceDataLibrary.UnitPrefix.Add(unitPrefix4); engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary); this.siteDirectory.Model.Add(engineeringModelSetup); this.openRdlList = new List <ReferenceDataLibrary>(this.siteDirectory.SiteReferenceDataLibrary) { modelReferenceDataLibrary }; this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.openRdlList)); var browser = new UnitPrefixBrowserViewModel(this.session.Object, this.siteDirectory, null, null, null, null); Assert.AreEqual(4, browser.UnitPrefixes.Count); }
/// <summary> /// Removes a <see cref="UnitPrefixRowViewModel"/> from the view model /// </summary> /// <param name="unitPrefix"> /// The <see cref="UnitPrefix"/> for which the row view model has to be removed /// </param> private void RemoveUnitPrefixRowViewModel(UnitPrefix unitPrefix) { var row = this.UnitPrefixes.SingleOrDefault(rowViewModel => rowViewModel.Thing == unitPrefix); if (row != null) { this.UnitPrefixes.RemoveAndDispose(row); } }
public Unit GetMolecularMass(UnitPrefix gramsUnitPrefix = UnitPrefix.none, UnitPrefix molUnitPrefix = UnitPrefix.none) { Unit grams = new Unit(0, new SubUnit(gramsUnitPrefix, BaseUnit.g, 1), new SubUnit(molUnitPrefix, BaseUnit.mol, -1)); for (int i = 0; i < elementList.Count; i++) { grams.TotalAmount += elementList[i].amount * elementList[i].element.atomicMass.TotalAmount; } return grams; }
public void Verify_that_IsUnitPrefixInChainOfRdls_returns_expected_result() { var unitPrefix = new UnitPrefix(); Assert.That(this.mRdl.IsUnitPrefixInChainOfRdls(unitPrefix), Is.False); this.sRdl1.UnitPrefix.Add(unitPrefix); Assert.That(this.mRdl.IsUnitPrefixInChainOfRdls(unitPrefix), Is.True); }
/// <summary> /// Gets scaling factor associated with unit prefix /// </summary> /// <param name="iPrefix">Requested unit prefix</param> /// <returns>Unit prefix scaling factor</returns> public static AmountType GetFactor(this UnitPrefix iPrefix) { #if DOUBLE return(Math.Pow(10.0, (double)iPrefix)); #elif SINGLE return((float)Math.Pow(10.0, (double)iPrefix)); #elif DECIMAL return((decimal)Math.Pow(10.0, (double)iPrefix)); #endif }
/// <summary> /// Adds a <see cref="UnitPrefixRowViewModel"/> /// </summary> /// <param name="unitPrefix"> /// The associated <see cref="UnitPrefix"/> for which the row is to be added. /// </param> private void AddUnitPrefixRowViewModel(UnitPrefix unitPrefix) { if (this.UnitPrefixes.Any(x => x.Thing == unitPrefix)) { return; } var row = new UnitPrefixRowViewModel(unitPrefix, this.Session, this); this.UnitPrefixes.Add(row); }
public VIFE_FB(byte data) { var record = VifeFbTable.ToDictionary(x => x.VIFFB)[(byte)(data & (byte)VariableDataRecordType.MBUS_DIB_VIF_WITHOUT_EXTENSION)]; // clear Extension bit Data = data; Extension = (data & 0x80) != 0; Units = record.Units; Unit = record.Unit; Quantity = record.Quantity; Magnitude = record.Magnitude(data); Prefix = UnitPrefix.GetUnitPrefix(record.Magnitude(data)); }
public void Verify_that_when_referenced_UnitPrefix_is_in_chain_of_rdls_no_result_is_returned() { var unitPrefix = new UnitPrefix { Iid = Guid.Parse("55e32513-9e45-4a63-8cd4-e84b2f320a8d") }; this.siteReferenceDataLibrary.UnitPrefix.Add(unitPrefix); this.prefixedUnit.Prefix = unitPrefix; var results = this.prefixedUnitRuleChecker.CheckWhetherReferencedUnitPrefixIsInChainOfRdls(this.prefixedUnit); Assert.That(results, Is.Empty); }
public void VerifyThatChangeMessageIsProcessed() { this.unitPrefix = new UnitPrefix(Guid.NewGuid(), null, this.uri); this.siteReferenceDataLibrary.UnitPrefix.Add(this.unitPrefix); var row = new UnitPrefixRowViewModel(this.unitPrefix, this.session.Object, null); this.unitPrefix.ShortName = "test"; this.revInfo.SetValue(this.unitPrefix, 10); CDPMessageBus.Current.SendObjectChangeEvent(this.unitPrefix, EventKind.Updated); Assert.AreEqual("test", row.ShortName); }
public void AsStringTest() { var unitBaseName = new UnitBaseName <ScalarFloat, float> { Name = "metre", AsciiSymbol = "m", Factor = new ScalarFloat(1), Symbol = "m" }; var unitPrefix = new UnitPrefix <ScalarFloat, float> { Name = "kilo", Symbol = "k", AsciiSymbol = "k", Factor = new ScalarFloat(1000), Invert = false }; var unitName = new UnitName <ScalarFloat, float>(unitPrefix, unitBaseName); Assert.AreEqual("km", unitName.AsString); }
public void Setup() { this.prefixedUnit = new PrefixedUnit(); this.unitPrefix = new UnitPrefix(); this.unitPrefix.ConversionFactor = "conv"; this.unitPrefix.Name = "unit"; this.unitPrefix.ShortName = "u"; this.measurementUnit = new SimpleUnit(); this.measurementUnit.Name = "measurement"; this.measurementUnit.ShortName = "m"; }
public void Verify_that_QueryUnitPrefixesFromChainOfRdls_returns_expected_result() { var mRdl_UnitPrefix = new UnitPrefix(Guid.NewGuid(), null, null); var sRdl1_UnitPrefix = new UnitPrefix(Guid.NewGuid(), null, null); var sRdl11_UnitPrefix = new UnitPrefix(Guid.NewGuid(), null, null); this.mRdl.UnitPrefix.Add(mRdl_UnitPrefix); this.sRdl1.UnitPrefix.Add(sRdl1_UnitPrefix); this.sRdl11.UnitPrefix.Add(sRdl11_UnitPrefix); Assert.That(new List <UnitPrefix> { mRdl_UnitPrefix, sRdl1_UnitPrefix, sRdl11_UnitPrefix }, Is.EquivalentTo(this.mRdl.QueryUnitPrefixesFromChainOfRdls())); }
public void Verify_that_when_referenced_DeprecatableThing_Is_not_Deprecated_no_result_is_returned() { var unitPrefix = new UnitPrefix { Iid = Guid.Parse("55e32513-9e45-4a63-8cd4-e84b2f320a8d"), ShortName = "PRE", IsDeprecated = false }; this.siteReferenceDataLibrary.UnitPrefix.Add(unitPrefix); this.prefixedUnit.Prefix = unitPrefix; var results = this.prefixedUnitRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.prefixedUnit); Assert.That(results, Is.Empty); }
public void VerifyThatUnitPrefixIsAddedAndRemoveWhenItIsSentAsObjectChangeMessage() { Assert.IsEmpty(this.browser.UnitPrefixes); var unitPrefix = new UnitPrefix(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "unitPrefix name", ShortName = "unitPrefixshortname", Container = this.siteRdl }; CDPMessageBus.Current.SendObjectChangeEvent(unitPrefix, EventKind.Added); Assert.AreEqual(1, this.browser.UnitPrefixes.Count); CDPMessageBus.Current.SendObjectChangeEvent(unitPrefix, EventKind.Removed); Assert.AreEqual(0, this.browser.UnitPrefixes.Count); }
public void Verify_that_when_referenced_UnitPrefix_is_not_in_chain_of_rdls_result_is_returned() { var unitPrefix = new UnitPrefix { Iid = Guid.Parse("55e32513-9e45-4a63-8cd4-e84b2f320a8d"), ShortName = "PRE" }; var otherSiterReferenceDataLibrary = new SiteReferenceDataLibrary(); otherSiterReferenceDataLibrary.UnitPrefix.Add(unitPrefix); this.prefixedUnit.Prefix = unitPrefix; var result = this.prefixedUnitRuleChecker.CheckWhetherReferencedUnitPrefixIsInChainOfRdls(this.prefixedUnit).First(); Assert.That(result.Id, Is.EqualTo("MA-0270")); Assert.That(result.Description, Is.EqualTo("The referenced UnitPrefix 55e32513-9e45-4a63-8cd4-e84b2f320a8d:PRE of PrefixedUnit.Prefix is not in the chain of Reference Data Libraries")); Assert.That(result.Thing, Is.EqualTo(this.prefixedUnit)); Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error)); }
public void VerifyThatPropertiesAreSet() { var filetype = new UnitPrefix { Name = "Prefix", ShortName = "p", ConversionFactor = "3" }; var transactionContext = TransactionContextResolver.ResolveContext(this.siteDir); var transaction = new ThingTransaction(transactionContext); var viewmodel = new UnitPrefixDialogViewModel(filetype, transaction, this.session.Object, true, ThingDialogKind.Create, this.thingDialogNavigationService.Object); Assert.IsNotEmpty(viewmodel.PossibleContainer); Assert.AreEqual(1, viewmodel.PossibleContainer.Count); Assert.AreEqual(viewmodel.Name, filetype.Name); Assert.AreEqual(viewmodel.ConversionFactor, filetype.ConversionFactor); Assert.AreEqual(viewmodel.ShortName, filetype.ShortName); Assert.AreEqual(viewmodel.IsDeprecated, filetype.IsDeprecated); Assert.AreEqual(this.srdl.Iid, viewmodel.Container.Iid); }
public void Verify_that_when_referenced_DeprecatableThing_Is_Deprecated_result_is_returned() { var unitPrefix = new UnitPrefix { Iid = Guid.Parse("55e32513-9e45-4a63-8cd4-e84b2f320a8d"), ShortName = "PRE", IsDeprecated = true }; this.siteReferenceDataLibrary.UnitPrefix.Add(unitPrefix); this.prefixedUnit.Prefix = unitPrefix; var result = this.prefixedUnitRuleChecker.ChecksWhetherAReferencedDeprecatableThingIsDeprecated(this.prefixedUnit).Single(); Assert.That(result.Id, Is.EqualTo("MA-0500")); Assert.That(result.Description, Is.EqualTo("The referenced UnitPrefix 55e32513-9e45-4a63-8cd4-e84b2f320a8d:PRE of PrefixedUnit.Prefix is deprecated")); Assert.That(result.Thing, Is.EqualTo(this.prefixedUnit)); Assert.That(result.Severity, Is.EqualTo(SeverityKind.Warning)); }
/// <summary> /// Serialize the <see cref="UnitPrefix"/> /// </summary> /// <param name="unitPrefix">The <see cref="UnitPrefix"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(UnitPrefix unitPrefix) { var jsonObject = new JObject(); jsonObject.Add("alias", this.PropertySerializerMap["alias"](unitPrefix.Alias.OrderBy(x => x, this.guidComparer))); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), unitPrefix.ClassKind))); jsonObject.Add("conversionFactor", this.PropertySerializerMap["conversionFactor"](unitPrefix.ConversionFactor)); jsonObject.Add("definition", this.PropertySerializerMap["definition"](unitPrefix.Definition.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](unitPrefix.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](unitPrefix.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](unitPrefix.HyperLink.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](unitPrefix.Iid)); jsonObject.Add("isDeprecated", this.PropertySerializerMap["isDeprecated"](unitPrefix.IsDeprecated)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](unitPrefix.ModifiedOn)); jsonObject.Add("name", this.PropertySerializerMap["name"](unitPrefix.Name)); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](unitPrefix.RevisionNumber)); jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](unitPrefix.ShortName)); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](unitPrefix.ThingPreference)); return(jsonObject); }
public void VerifyThatTheConstructorSetsTheProperties() { var shortname = "unitPrefixshortname"; var name = "unitPrefix name"; var conversionFactor = "conversionFactor"; this.unitPrefix = new UnitPrefix(Guid.NewGuid(), null, this.uri) { Name = name, ShortName = shortname, ConversionFactor = conversionFactor, Container = this.siteReferenceDataLibrary }; this.siteReferenceDataLibrary.UnitPrefix.Add(this.unitPrefix); var unitPrefixRowViewModel = new UnitPrefixRowViewModel(this.unitPrefix, this.session.Object, null); Assert.AreEqual(shortname, unitPrefixRowViewModel.ShortName); Assert.AreEqual(name, unitPrefixRowViewModel.Name); Assert.AreEqual(conversionFactor, unitPrefixRowViewModel.ConversionFactor); Assert.AreEqual(this.siteReferenceDataLibrary.ShortName, unitPrefixRowViewModel.ContainerRdl); Assert.AreEqual(0, unitPrefixRowViewModel.ContainedRows.Count); }
public void VerifyThatGetRequiredRdlsReturnsExpectedResults() { var srdl1 = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); var srdl1_1 = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); var mrdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); var srdl2 = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); var unitPrefix = new UnitPrefix(Guid.NewGuid(), this.cache, this.uri); srdl1_1.RequiredRdl = srdl1; mrdl.RequiredRdl = srdl1_1; srdl2.RequiredRdl = srdl1; mrdl.UnitPrefix.Add(unitPrefix); var requiredRdls = unitPrefix.RequiredRdls.ToList(); Assert.IsTrue(requiredRdls.Contains(mrdl)); Assert.IsTrue(requiredRdls.Contains(srdl1_1)); Assert.IsTrue(requiredRdls.Contains(srdl1)); Assert.IsFalse(requiredRdls.Contains(srdl2)); }
public void VerifyThatCommandsBecomeEnabled() { Assert.IsEmpty(this.browser.UnitPrefixes); var unitPrefix = new UnitPrefix(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "unitPrefix name", ShortName = "unitPrefixshortname", Container = this.siteRdl }; CDPMessageBus.Current.SendObjectChangeEvent(unitPrefix, EventKind.Added); Assert.AreEqual(1, this.browser.UnitPrefixes.Count); Assert.IsFalse(this.browser.InspectCommand.CanExecute(null)); Assert.IsFalse(this.browser.UpdateCommand.CanExecute(null)); this.browser.SelectedThing = this.browser.UnitPrefixes.First(); this.browser.ComputePermission(); Assert.IsTrue(this.browser.InspectCommand.CanExecute(null)); Assert.IsTrue(this.browser.UpdateCommand.CanExecute(null)); }
/// <summary> /// Gets printed symbol associated with unit prefix /// </summary> /// <param name="iPrefix">Requested unit prefix</param> /// <returns>Unit prefix symbol</returns> public static string GetSymbol(this UnitPrefix iPrefix) { return(smkPrefixSymbolsMap[iPrefix]); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.dialogService = new Mock <IThingDialogNavigationService>(); this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); var person = new Person(Guid.NewGuid(), null, null) { Container = this.siteDir }; this.session.Setup(x => x.ActivePerson).Returns(person); this.siteDir = new SiteDirectory(Guid.NewGuid(), null, null); this.siteDir.Person.Add(person); this.genericSiteReferenceDataLibrary = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null) { Name = "Generic RDL", ShortName = "GENRDL" }; this.siteDir.SiteReferenceDataLibrary.Add(this.genericSiteReferenceDataLibrary); var kiloPrefix = new UnitPrefix(Guid.NewGuid(), null, null) { ShortName = "k", Name = "kilo" }; this.genericSiteReferenceDataLibrary.UnitPrefix.Add(kiloPrefix); var miliPrefix = new UnitPrefix(Guid.NewGuid(), null, null) { ShortName = "m", Name = "milli" }; this.genericSiteReferenceDataLibrary.UnitPrefix.Add(miliPrefix); var simpleUnit = new SimpleUnit(Guid.NewGuid(), null, null) { Name = "gram", ShortName = "g" }; this.genericSiteReferenceDataLibrary.Unit.Add(simpleUnit); var siteRdl1 = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null); var centiPrefix = new UnitPrefix(Guid.NewGuid(), null, null) { ShortName = "c", Name = "centi" }; siteRdl1.UnitPrefix.Add(centiPrefix); this.siteDir.SiteReferenceDataLibrary.Add(siteRdl1); this.genericSiteReferenceDataLibrary.RequiredRdl = siteRdl1; var transactionContext = TransactionContextResolver.ResolveContext(this.siteDir); this.transaction = new ThingTransaction(transactionContext, null); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary)); var dal = new Mock <IDal>(); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); }
public UnitNamePower(UnitPrefix <S, T> prefix, UnitBaseName <S, T> baseName, long power) : this(new UnitName <S, T>(prefix, baseName), power) { }
public UnitNamePower(UnitPrefix <S, T> prefix, UnitBaseName <S, T> baseName) : this(prefix, baseName, 1) { }
public SubUnit(UnitPrefix unitPrefixT,BaseUnit baseUnitT, int powerT) { unitPrefix = unitPrefixT; baseUnit = baseUnitT; power = powerT; }
/// <summary> /// Convenience constructor for initializing prefixed non-standard unit /// </summary> /// <param name="iPrefix">Prefix to use in unit naming and scaling vis-a-vis standard unit</param> public Unit(UnitPrefix iPrefix) : this(String.Format("{0}{1}", iPrefix.GetSymbol(), default(Q).StandardUnit), iPrefix.GetFactor()) { }
public gramLitreConcentration(decimal concentrationValueT, Molecule moleculeT, UnitPrefix gramsPrefix, UnitPrefix litrePrefix) { molecule = moleculeT; concentration = new Unit(concentrationValueT, new SubUnit(gramsPrefix, BaseUnit.g, 1), new SubUnit(litrePrefix, BaseUnit.L, -1)); }
public MolarConcentration(decimal concentrationValueT,Molecule moleculeT, UnitPrefix molPrefix, UnitPrefix litrePrefix) { molecule = moleculeT; concentration = new Unit(concentrationValueT, new SubUnit(molPrefix, BaseUnit.mol, 1), new SubUnit(litrePrefix, BaseUnit.L, -1)); }
/// <summary> /// Gets scaling factor associated with unit prefix /// </summary> /// <param name="iPrefix">Requested unit prefix</param> /// <returns>Unit prefix scaling factor</returns> public static float GetFactor(this UnitPrefix iPrefix) => (float)Math.Pow(x: 10.0, y: (double)iPrefix);