Beispiel #1
0
        /// <summary>
        /// 判断是否数据源内容
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        static public bool IsSourceLine(string line)
        {
            if (String.IsNullOrWhiteSpace(line) || line.Length < 3)
            {
                return(false);
            }

            var first3Char = line.Substring(0, 3);

            return(SourceTypeHelper.IsSource(first3Char));
        }
Beispiel #2
0
        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);
        }