Exemple #1
0
        public Magnetization(double value, UnitSystem unitSystem)
        {
            if (unitSystem is null)
            {
                throw new ArgumentNullException(nameof(unitSystem));
            }

            _value = Guard.EnsureValidNumber(value, nameof(value));

            var defaultUnitInfo = unitSystem.GetDefaultUnitInfo(QuantityType) as UnitInfo <MagnetizationUnit>;

            _unit = defaultUnitInfo?.Value ?? throw new ArgumentException("No default unit was defined for the given UnitSystem.", nameof(unitSystem));
        }
Exemple #2
0
        public Magnetization ToUnit(UnitSystem unitSystem)
        {
            if (unitSystem is null)
            {
                throw new ArgumentNullException(nameof(unitSystem));
            }

            var defaultUnitInfo = unitSystem.GetDefaultUnitInfo(QuantityType) as UnitInfo <MagnetizationUnit>;

            if (defaultUnitInfo == null)
            {
                throw new ArgumentException("No default unit was found for the given UnitSystem.", nameof(unitSystem));
            }

            return(ToUnit(defaultUnitInfo.Value));
        }
        public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem)
        {
            if (unitSystem is null)
            {
                throw new ArgumentNullException(nameof(unitSystem));
            }

            var defaultUnitInfo = unitSystem.GetDefaultUnitInfo(QuantityType) as UnitInfo <ElectricSurfaceChargeDensityUnit>;

            if (defaultUnitInfo == null)
            {
                throw new ArgumentException("No default unit was found for the given UnitSystem.", nameof(unitSystem));
            }

            return(ToUnit(defaultUnitInfo.Value));
        }
Exemple #4
0
        public double As(UnitSystem unitSystem)
        {
            if (unitSystem is null)
            {
                throw new ArgumentNullException(nameof(unitSystem));
            }

            var defaultUnitInfo = unitSystem.GetDefaultUnitInfo(QuantityType) as UnitInfo <AreaMomentOfInertiaUnit>;

            if (defaultUnitInfo == null)
            {
                throw new ArgumentException("No default unit was found for the given UnitSystem.", nameof(unitSystem));
            }

            return(As(defaultUnitInfo.Value));
        }
Exemple #5
0
        public RotationalStiffnessPerLength ToUnit(UnitSystem unitSystem)
        {
            if (unitSystem is null)
            {
                throw new ArgumentNullException(nameof(unitSystem));
            }

            var defaultUnitInfo = unitSystem.GetDefaultUnitInfo(QuantityType) as UnitInfo <RotationalStiffnessPerLengthUnit>;

            if (defaultUnitInfo == null)
            {
                throw new ArgumentException("No default unit was found for the given UnitSystem.", nameof(unitSystem));
            }

            return(ToUnit(defaultUnitInfo.Value));
        }