/// <summary>
        /// Parameterless constructor that sets up all the default values of the options
        /// </summary>
        public MeasurementOptions()
        {
            // Defaults - General
            AllowReorderingDimensions = true;

            // Defaults - Dimensions
            AllowDerivedDimensions = true;
            AllowVectorDimensions  = false;
            IgnoredDimensions      = new List <DimensionDefinition>();

            // Defaults - Units
            UseEstimatedUnits = false;
            UseRareUnits      = false;

            // Defaults - Measurement Systems
            AllowedSystemsForUnits = new List <MeasurementSystem>();
            IgnoredSystemsForUnits = new List <MeasurementSystem>();

            // Defaults - Prefixes
            UseAutomaticPrefixManagement = true;
            UseRarePrefixes               = false;
            UseUnofficalPrefixes          = false;
            AllowedRarePrefixCombinations = new List <KeyValuePair <Unit, Prefix> > {
                new KeyValuePair <Unit, Prefix>(
                    MeasurementCorpus.FindUnit("metre"), MeasurementCorpus.FindPrefix("centi"))
            };
            PreferBinaryPrefixes    = true;
            UpperPrefixValue        = 1000;
            LowerPrefixValue        = 1;
            HavingPrefixScoreOffset = 1;

            // Defaults - Formatting
            QuantityFormat = new QuantityFormatInfo();
        }
Esempio n. 2
0
 /// <summary>
 /// Explicit implementation of IObjectReference to make sure dimension
 /// is instantiated properly during deserialization.
 /// </summary>
 object IObjectReference.GetRealObject(StreamingContext context)
 {
     return(new Dimension {
         Unit = MeasurementCorpus.FindUnit(_unitName, _systemName),
         Power = _power ?? DEFAULT_POWER,
         Prefix = (_prefixName == null) ? null : MeasurementCorpus.FindPrefix(_prefixName)
     });
 }
Esempio n. 3
0
 /// <summary>
 /// Converts a quantity based on a unit that matches an existing dimension.
 /// </summary>
 /// <param name="unitName">The name of the unit to convert</param>
 /// <returns>The converted quantity</returns>
 public Quantity <TNumber> Convert(string unitName)
 {
     return(Convert(MeasurementCorpus.FindUnit(unitName)));
 }
Esempio n. 4
0
 /// <summary>
 /// Helper constructor with unit name, system name, power, and prefix name so
 /// the unit can be fully specified.
 /// </summary>
 /// <param name="unitName">The unit name</param>
 /// <param name="systemName">The name of the system the unit is in</param>
 /// <param name="power">The power of the dimension</param>
 /// <param name="prefixName">The optional name of the prefix</param>
 public Dimension(string unitName, string systemName, int power, string prefixName = null)
     : this(MeasurementCorpus.FindUnit(unitName, systemName), power,
            MeasurementCorpus.FindPrefix(prefixName))
 {
 }