public void TestFixtureSetUp() { DmsConversion = new SexagesimalDmsToDecimalDegreesConversion(new SimpleUnit("Sexagesimal DMS"), new SimpleUnit("degrees")); DmsInverse = DmsConversion.GetInverse(); DmConversion = new SexagesimalDmToDecimalDegreesConversion(new SimpleUnit("Sexagesimal DM"), DmsConversion.To); DmInverse = DmConversion.GetInverse(); }
/// <summary> /// /// </summary> /// <param name="abbreviation"></param> /// <param name="toBase"></param> /// <param name="fromBase"></param> /// <param name="mass"></param> /// <param name="acceleration"></param> protected ForceBase(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase, IMass mass, IAcceleration acceleration) : base(abbreviation, toBase, fromBase, mass, acceleration) { VerifyDimensions(); }
public BinaryUnitConversionMap(IUnitConversion<double> forwardOperation, IEqualityComparer<IUnit> unitEqualityComparer = null) : base(unitEqualityComparer) { if (null == forwardOperation) throw new ArgumentNullException("forwardOperation"); Contract.EndContractBlock(); _forwardOperation = forwardOperation; }
/// <summary> /// /// </summary> /// <param name="abbreviation"></param> /// <param name="toBase"></param> /// <param name="fromBase"></param> /// <param name="surfaceArea"></param> /// <param name="squareRadius"></param> protected SolidAngleBase(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase, IArea surfaceArea, ILength squareRadius) : base(abbreviation, toBase, fromBase, surfaceArea, squareRadius) { VerifyDimensions(); }
private static void VerifyUnitConversion(IUnitConversion conversion, int exponent, double result) { Assert.That(conversion, Is.Not.Null); var actual = conversion.Convert(BaseConversionStartValue, exponent); Assert.That(actual, Is.EqualTo(result).Within(Epsilon)); }
/// <summary> /// /// </summary> /// <param name="abbreviation"></param> /// <param name="toBase"></param> /// <param name="fromBase"></param> /// <param name="dimensions"></param> protected DerivedDimension(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase, params IDimension[] dimensions) : base(abbreviation) { //TODO: may order these, by exponent? _dimensions.AddRange(dimensions); ToBase = toBase ?? new DerivedUnitConversion(() => Dimensions, d => d.ToBase); FromBase = fromBase ?? new DerivedUnitConversion(() => Dimensions, d => d.FromBase); }
public BinaryUnitConversionMap(IUnitConversion <double> forwardOperation, IEqualityComparer <IUnit> unitEqualityComparer = null) : base(unitEqualityComparer) { if (null == forwardOperation) { throw new ArgumentNullException("forwardOperation"); } Contract.EndContractBlock(); _forwardOperation = forwardOperation; }
private IEnumerable <IUnitConversion <double> > Linearize(IUnitConversion <double> conversion) { Contract.Requires(conversion != null); Contract.Ensures(Contract.Result <IEnumerable <IUnitConversion <double> > >() != null); Contract.Ensures(Contract.ForAll(Contract.Result <IEnumerable <IUnitConversion <double> > >(), x => x != null)); var catConv = conversion as ConcatenatedUnitConversion; if (null == catConv) { return(ArrayUtil.CreateSingleElementArray(conversion)); } return(Linearize(catConv.Conversions)); }
public ConvertorInstance(IUnitConversion conversionEntry, IServiceLocator locator) { if (!string.IsNullOrWhiteSpace(conversionEntry.ConvertorClass)) { m_convertor = locator.InstantiateNow <IUnitConvertor>(conversionEntry.ConvertorClass); } else { if (conversionEntry.Multiplier == null) { throw new InvalidOperationException("Conversion must have convertor class or mutiplier"); } m_convertor = new DefaultConvertor(conversionEntry.Multiplier.Value); } }
public ReadOnlyUnitConversionMap(IEnumerable<IUnitConversion<double>> conversions, IEqualityComparer<IUnit> unitEqualityComparer = null) : base(unitEqualityComparer) { if (null == conversions) throw new ArgumentNullException("conversions"); Contract.EndContractBlock(); _allConversions = conversions.ToArray(); _allDistinctUnits = _allConversions .Select(x => x.From) .Concat(_allConversions.Select(x => x.To)) .Distinct(EqualityComparer) .ToArray(); _fromMap = _allConversions .ToLookup(x => x.From, EqualityComparer) .ToDictionary(x => x.Key, x => x.ToArray(), EqualityComparer); _toMap = _allConversions .ToLookup(x => x.To, EqualityComparer) .ToDictionary(x => x.Key, x => x.ToArray(), EqualityComparer); }
public IMaterialUnit GetSmallestCompatibleUnit(IMaterialUnit u) { IUnitConversion smallest = null; foreach (var conversion in GetAllConversions().Where(c => c.SourceUnitId == u.Id)) { if ((smallest?.Multiplier ?? 1) < conversion.Multiplier) { smallest = conversion; } } if (smallest == null) { return(u); } return(m_unitRepository.GetUnit(smallest.TargetUnitId)); }
private bool ConversionIsUnity(IUnitConversion <double> conversion) { if (conversion == null) { return(false); } if (conversion is UnitUnityConversion) { return(true); } var scalar = conversion as IUnitScalarConversion <double>; if (scalar != null) { return(scalar.Factor == 1.0); } return(false); }
private Length(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase) : base(abbreviation, toBase, fromBase) { }
/// <summary> /// Protected Constructor /// </summary> /// <param name="abbreviation"></param> /// <param name="toBase"></param> /// <param name="fromBase"></param> protected Dimension(string abbreviation, IUnitConversion toBase = null, IUnitConversion fromBase = null) : this(abbreviation) { ToBase = toBase ?? BaseDimensionUnitConversion.DefaultConversion; FromBase = fromBase ?? BaseDimensionUnitConversion.DefaultConversion; }
private Prefix(string abbreviation = null, IUnitConversion toBase = null, IUnitConversion fromBase = null) : base(abbreviation, toBase, fromBase) { }
private SubstanceAmount(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase) : base(abbreviation, toBase, fromBase) { }
/// <summary> /// Protected Constructor /// </summary> /// <param name="abbreviation"></param> /// <param name="toBase"></param> /// <param name="fromBase"></param> /// <param name="arc"></param> /// <param name="radius"></param> protected PlanarAngleBase(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase, ILength arc, ILength radius) : base(abbreviation, toBase, fromBase, arc, radius) { }
public SpheroidLinearUnitConversionWrapper(ISpheroidInfo spheroid, IUnitConversion <double> conversion) : this(spheroid, conversion.To, conversion.TransformValue(spheroid.A), conversion.TransformValue(spheroid.B)) { Contract.Requires(spheroid != null); Contract.Requires(conversion != null); }
/// <summary> /// Private Constructor /// </summary> /// <param name="abbreviation"></param> /// <param name="toBase"></param> /// <param name="fromBase"></param> /// <param name="mass"></param> /// <param name="acceleration"></param> private Force(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase, IMass mass, IAcceleration acceleration) : base(abbreviation, toBase, fromBase, mass, acceleration) { }
private Temperature(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase) : base(abbreviation, toBase, fromBase) { }
public InvertedConversion(IUnitConversion source) { Multiplier = 1m / (source.Multiplier ?? 1m); SourceUnitId = source.TargetUnitId; TargetUnitId = source.SourceUnitId; }
private SolidAngle(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase, IArea surfaceArea, ILength squareRadius) : base(abbreviation, toBase, fromBase, surfaceArea, squareRadius) { }
private Force(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase, IMass mass, IAcceleration acceleration) : base(abbreviation, toBase, fromBase, mass, acceleration) { }
public SpheroidLinearUnitConversionWrapper(ISpheroidInfo spheroid, IUnitConversion<double> conversion) : this(spheroid, conversion.To, conversion.TransformValue(spheroid.A), conversion.TransformValue(spheroid.B)) { Contract.Requires(spheroid != null); Contract.Requires(conversion != null); }
/// <summary> /// /// </summary> /// <param name="abbreviation"></param> /// <param name="toBase"></param> /// <param name="fromBase"></param> protected BaseDimension(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase) : base(abbreviation, toBase, fromBase) { }
/// <summary> /// /// </summary> /// <param name="abbreviation"></param> /// <param name="toBase"></param> /// <param name="fromBase"></param> protected EnergyBase(string abbreviation, IUnitConversion toBase, IUnitConversion fromBase) : base(abbreviation, toBase, fromBase) { }