Пример #1
0
        public BaseQuantity(string name)
        {
            Name     = name ?? throw new ArgumentNullException(nameof(name));
            Symbol   = null;
            UISymbol = null;

            MetricSystemManager.AddQuantity(this);
        }
Пример #2
0
        public MetricSystem(string name)
        {
            Name     = name ?? throw new ArgumentNullException(nameof(name));
            units    = new HashSet <Unit>();
            prefixes = new HashSet <MetricPrefix>();

            MetricSystemManager.AddMetricSystem(this);
        }
Пример #3
0
        public MetricSystem(string name, IList <Unit> units)
        {
            Name       = name ?? throw new ArgumentNullException(nameof(name));
            FullName   = null;
            this.units = new HashSet <Unit>(units ?? throw new ArgumentNullException(nameof(units)));
            prefixes   = new HashSet <MetricPrefix>();

            MetricSystemManager.AddMetricSystem(this);
        }
Пример #4
0
 private static bool tryParseByFullName(string uiSymbol, out MetricPrefix result)
 {
     result = MetricSystemManager.GetAllMetricPrefixes().FirstOrDefault(u => u.UISymbol == uiSymbol);
     if (result == default)
     {
         return(false);
     }
     return(true);
 }
Пример #5
0
 private static bool tryParseByFullName(string uiSymbol, out MetricSystem result)
 {
     result = MetricSystemManager.GetAllMetricSystems()
              .FirstOrDefault(ms => ms.FullName == uiSymbol);
     if (result == default)
     {
         return(false);
     }
     return(true);
 }
Пример #6
0
        private static bool tryParseByName(string name, out Unit result)
        {
            result = MetricSystemManager.GetAllUnits().FirstOrDefault(u => u.Name == name);
            if (result == default)
            {
                return(false);
            }

            return(true);
        }
Пример #7
0
        private static bool tryParseByUISymbol(string uiSymbol, out Unit result)
        {
            result = MetricSystemManager.GetAllUnits().FirstOrDefault(u => u.UISymbol == uiSymbol);
            if (result == default)
            {
                return(false);
            }

            return(true);
        }
Пример #8
0
        private static bool tryParseByName(string name, out Quantity result)
        {
            result = MetricSystemManager.GetAllQuantities().FirstOrDefault(q => q.Name == name);
            if (result == null)
            {
                return(false);
            }

            return(true);
        }
Пример #9
0
        private static bool tryParseByUISymbol(string uiSymbol, out Quantity result)
        {
            result = MetricSystemManager.GetAllQuantities().FirstOrDefault(q => q.UISymbol == uiSymbol);
            if (result == null)
            {
                return(false);
            }

            return(true);
        }
Пример #10
0
        private static bool tryParseBySymbol(string symbol, out MetricPrefix result)
        {
            result = MetricSystemManager.GetAllMetricPrefixes().FirstOrDefault(q => q.Symbol == symbol);
            if (result == null)
            {
                return(false);
            }

            return(true);
        }
Пример #11
0
 public void Dispose()
 {
     MetricSystemManager.RemoveMetricSystem(this);
 }
Пример #12
0
 /// <summary>
 /// Gets all the available metric systems.
 /// </summary>
 /// <returns>The available metric systems.</returns>
 public static IEnumerable <MetricSystem> GetAll()
 => MetricSystemManager.GetAllMetricSystems();
Пример #13
0
 public override void Dispose()
 {
     MetricSystemManager.RemoveQuantity(this);
 }
Пример #14
0
 /// <summary>
 /// Gets all the available units.
 /// </summary>
 /// <returns>The available units.</returns>
 public static IEnumerable <Unit> GetAll() => MetricSystemManager.GetAllUnits();
Пример #15
0
 /// <summary>
 /// Gets all the available quantitites.
 /// </summary>
 /// <returns>The available quantities.</returns>
 public static IEnumerable <Quantity> GetAll()
 => MetricSystemManager.GetAllQuantities();
Пример #16
0
 /// <summary>
 /// Gets all the available metric prefixes.
 /// </summary>
 /// <returns>The available metric prefixes.</returns>
 public static IEnumerable <MetricPrefix> GetAll() => MetricSystemManager.GetAllMetricPrefixes();