public static NtripSourceTable Load(string path) { var manager = new NtripSourceTable(); using (StreamReader reader = new StreamReader(path, Encoding.Default)) { string line = null; while ((line = reader.ReadLine()) != null) { if (IsSourceLine(line)) { INtripSourceItem item; var first3Char = line.Substring(0, 3); var type = SourceTypeHelper.GetSourceType(first3Char); switch (type) { case SourceType.Stream: var NtripStreamItem = NtripStream.Parse(line); NtripStreamItem.CasterName = Path.GetFileNameWithoutExtension(path).Replace("-table", ""); item = NtripStreamItem; break; case SourceType.Caster: item = NtripCasterItem.Parse(line); break; case SourceType.Network: item = NtripNetwork.Parse(line); break; default: item = NtripCasterItem.Parse(line); break; } manager.GetOrCreate(item.SourceType).Add(item); } } } return(manager); }
public static NtripNetwork Parse(string line) { var item = new NtripNetwork(); string[] fields = line.Split(';'); string first = fields[0].ToUpper(); if (first != "NET") { throw new NotSupportedException("字符串错误"); } int i = 1; item.Identifier = fields[i++]; item.Operator = fields[i++]; item.Authentication = fields[i++]; item.Fee = fields[i++]; item.WebNet = fields[i++]; item.WebStr = fields[i++]; item.WebReg = fields[i++]; item.Misc = fields[i++]; return(item); }