Пример #1
0
        /// <summary> 读取关键字 </summary>
        public override BaseKey ReadKeyLine(StreamReader reader)
        {
            string tempStr = string.Empty;

            while (!reader.EndOfStream)
            {
                tempStr = reader.ReadLine().Trim();

                if (!tempStr.IsWorkLine())
                {
                    continue;
                }

                //  首先读取DefautRegion  1 40 1 20 1 4 /
                if (region == null)
                {
                    region = new RegionParam();
                    region.BuildExtend(tempStr);
                    this.DefautRegion = region;
                }

                //  读到结束符结束
                if (tempStr == endFlag)
                {
                    break;
                }

                bool isChildRegister = KeyConfigerFactroy.Instance.IsChildRegisterKey(tempStr);

                if (isChildRegister)
                {
                    //  读到下一关注关键字终止
                    BaseKey tempKey = KeyConfigerFactroy.Instance.CreateChildKey <BaseKey>(tempStr);

                    //  是修正关键字
                    if (tempKey is ModifyKey)
                    {
                        tempKey.BaseFile  = this.BaseFile;
                        tempKey.ParentKey = this;

                        ModifyKey mk = tempKey as ModifyKey;
                        this.Keys.Add(mk);
                        mk.BaseFile = this.BaseFile;
                        mk.ReadKeyLine(reader);

                        ////  执行更改
                        //mk.RunModify();
                    }
                    else if (tempKey is TableKey)
                    {
                        ReadBOX(reader, tempStr);

                        return(null);
                    }

                    else
                    {
                        ReadBOX(reader, tempStr);

                        return(null);
                    }
                }
                else
                {
                    if (tempStr.IsKeyFormat())
                    {
                        UnkownKey findKey = new UnkownKey(KeyChecker.FormatKey(tempStr));

                        findKey.BaseFile = this.BaseFile;

                        //  触发事件
                        if (findKey.BaseFile != null && findKey.BaseFile.OnUnkownKey != null)
                        {
                            findKey.BaseFile.OnUnkownKey(findKey.BaseFile, findKey);
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(tempStr))
                        {
                            //  不是记录行
                            this.Lines.Add(tempStr);
                        }
                    }
                }
            }

            //  读到末尾返回空值
            return(null);
        }
Пример #2
0
        /// <summary> 读取关键字 </summary>
        public override BaseKey ReadKeyLine(StreamReader reader)
        {
            string tempStr = string.Empty;

            while (!reader.EndOfStream)
            {
                tempStr = reader.ReadLine().TrimEnd();

                if (!tempStr.IsWorkLine())
                {
                    continue;
                }

                #region - 构建结构 -

                if (string.IsNullOrEmpty(this.carName))
                {
                    //  首先读取结构参数  'LGR1' 2 2 3 3 3 4   5   5   8 5 /
                    List <string> strs = tempStr.EclExtendToArray();

                    if (this.carName == null)
                    {
                        this.carName = strs[0];

                        region       = new RegionParam();
                        region.XFrom = strs[1].ToInt();
                        region.XTo   = strs[2].ToInt();
                        region.YFrom = strs[3].ToInt();
                        region.YTo   = strs[4].ToInt();
                        region.ZFrom = strs[5].ToInt();
                        region.ZTo   = strs[6].ToInt();

                        this.X = strs[7].ToInt();
                        this.Y = strs[8].ToInt();
                        this.Z = strs[9].ToInt();

                        newRegion.XFrom = 1;
                        newRegion.XTo   = this.x;
                        newRegion.YFrom = 1;
                        newRegion.YTo   = this.y;
                        newRegion.ZFrom = 1;
                        newRegion.ZTo   = this.z;


                        defaultRegion = newRegion;
                    }
                }

                #endregion

                //  读到结束符结束
                if (tempStr == _carfinEndFlag)
                {
                    break;
                }

                //  读到本关键字信息 处理两个CARFIN用一个ENDFIN问题
                if (tempStr == this.Name)
                {
                    BaseKey findKey = KeyConfigerFactroy.Instance.CreateKey <BaseKey>(tempStr, this.BaseFile.SimKeyType);
                    findKey.BaseFile  = this.BaseFile;
                    findKey.ParentKey = this.ParentKey;
                    this.ParentKey.Add(findKey);
                    //  调用子节点读取方法
                    findKey.ReadKeyLine(reader);
                    break;
                }

                bool isChildRegister = KeyConfigerFactroy.Instance.IsRegister(tempStr, this.BaseFile.SimKeyType);

                if (isChildRegister)
                {
                    //  读到下一关注关键字终止
                    BaseKey tempKey = KeyConfigerFactroy.Instance.CreateKey <BaseKey>(tempStr, this.BaseFile.SimKeyType);

                    //  是修正关键字
                    if (tempKey is ModifyKey)
                    {
                        tempKey.BaseFile  = this.BaseFile;
                        tempKey.ParentKey = this;

                        ModifyKey mk = tempKey as ModifyKey;
                        mk.DefautRegion = this.defaultRegion;
                        //  放入本定义下面
                        this._modifyKeyCar.Add(mk);
                        mk.BaseFile = this.BaseFile;
                        mk.ReadKeyLine(reader);

                        this.defaultRegion = mk.DefautRegion;

                        //  增加子修正关键字 如BOX
                        //this._modifyKeyCar.AddRange(mk.FindAll<ModifyKey>());
                    }
                    else if (tempKey is DynamicKey)
                    {
                        tempKey.BaseFile  = this.BaseFile;
                        tempKey.ParentKey = this;

                        //  放入本子节点下面
                        this.Keys.Add(tempKey);
                        tempKey.ReadKeyLine(reader);
                    }
                    else if (tempKey is TableKey)
                    {
                        ReadBOX(reader, tempStr);

                        return(this);
                    }

                    else
                    {
                        ReadBOX(reader, tempStr);

                        return(this);
                    }
                }
                else
                {
                    if (tempStr.IsKeyFormat())
                    {
                        UnkownKey findKey = new UnkownKey(KeyChecker.FormatKey(tempStr));

                        findKey.BaseFile = this.BaseFile;

                        //  触发事件
                        if (findKey.BaseFile != null && findKey.BaseFile.OnUnkownKey != null)
                        {
                            findKey.BaseFile.OnUnkownKey(findKey.BaseFile, findKey);
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(tempStr))
                        {
                            //  不是记录行
                            this.Lines.Add(tempStr);
                        }
                    }
                }
            }

            //  读到末尾返回空值
            return(this);
        }