Inheritance: StandardPrefixes
Exemplo n.º 1
0
        public static bool HasPrefix(string value, out string prefix)
        {
            MetricPrefixes m = Instance;

            prefix = "";
            bool hasPrefix = (value != null && value.Length >= 1 && prefixes.ContainsKey(value.Trim().Substring(0, 1)));

            if (hasPrefix)
            {
                prefix = value.Trim().Substring(0, 1);
            }
            return(hasPrefix);
        }
Exemplo n.º 2
0
        public StandardUnit(string value)
        {
            //--------------------------//
            //--- Extract the prefix ---//
            //--------------------------//
            string prefix;

            if (!BinaryPrefixes.HasPrefix(value, out prefix))
            {
                MetricPrefixes.HasPrefix(value, out prefix);
            }
            Prefix = prefix;
            Unit   = value.Substring(Prefix.Length);
            var rgx = new Regex(PATTERN);

            if (!rgx.Match(Unit).Success)
            {
                Prefix = null;
                Unit   = null;
            }
        }
Exemplo n.º 3
0
        public static StandardUnitPrefix GetPrefix(string prefix)
        {
            MetricPrefixes m = Instance;

            return(prefixes.ContainsKey(prefix) ? prefixes[prefix] : null);
        }