Inheritance: StandardPrefixes
コード例 #1
0
        public static bool HasPrefix(string value, out string prefix)
        {
            BinaryPrefixes i = BinaryPrefixes.Instance;

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

            if (hasPrefix)
            {
                prefix = value.Trim().Substring(0, 2);
            }
            return(hasPrefix);
        }
コード例 #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;
            }
        }
コード例 #3
0
        public static StandardUnitPrefix GetPrefix(string prefix)
        {
            BinaryPrefixes i = BinaryPrefixes.Instance;

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