Ejemplo n.º 1
0
        public static HashSet <Code> Read(string name)
        {
            var filename   = PathUtils.GetTestTextFilename(name, "Decoder");
            int lineNumber = 0;
            var hash       = new HashSet <Code>();

            foreach (var line in File.ReadLines(filename))
            {
                lineNumber++;
                if (line.Length == 0 || line[0] == '#')
                {
                    continue;
                }
                var value = line.Trim();
                if (CodeUtils.IsIgnored(value))
                {
                    continue;
                }
                if (!ToEnumConverter.TryCode(value, out var code))
                {
                    throw new InvalidOperationException($"Error parsing Code file '{filename}', line {lineNumber}: Invalid value: {value}");
                }
                hash.Add(code);
            }
            return(hash);
        }
Ejemplo n.º 2
0
 static Code ToCode(string value)
 {
     if (!ToEnumConverter.TryCode(value, out var code))
     {
         throw new InvalidOperationException($"Invalid Code value: '{value}'");
     }
     return(code);
 }