Пример #1
0
        private void SlurpReferenceRKs(TextReader reader, bool checkAltKeyFields)
        {
            const int keyLen = 8 + 1 + 8 + 1 + 16;//TTTTTTTT:GGGGGGGG:IIIIIIIIIIIIIIII
            string absoluteName, line = reader.ReadLine();
            int linePos = 0;
            int index = -1;
            int i, foundIndex, keyOffset;

            while (line != null)
            {
                this.textLines.Add(line);
                keyOffset = 4;
                index = line.IndexOf("key:", linePos);
                if (index == -1 && checkAltKeyFields)
                {
                    index = line.IndexOf("key=\"", linePos);
                    if (index != -1) keyOffset = 5;
                }
                while (index == -1)
                {
                    line = reader.ReadLine();
                    if (line == null)
                        break;
                    this.textLines.Add(line);

                    linePos = 0;
                    index = line.IndexOf("key:", linePos);
                    if (index == -1 && checkAltKeyFields)
                    {
                        index = line.IndexOf("key=\"", linePos);
                        if (index != -1) keyOffset = 5;
                    }
                }
                linePos += keyOffset + keyLen;
                if (linePos > line.Length)
                {
                    line = reader.ReadLine();
                    continue;
                }

                string rkStr = line.Substring(index + keyOffset, keyLen);
                RK rk;
                if (ParseRK(rkStr, out rk))
                {
                    RKPos rkPos = null;
                    foundIndex = -1;
                    for (i = 0; i < this.oldToNewRKs.Count && foundIndex < 0; i++)
                    {
                        rkPos = this.oldToNewRKs[i];
                        if (rkPos.OldResourceKey.Equals(rk))
                            foundIndex = i;
                    }
                    if (foundIndex == -1 && (base.validate == null || base.validate(rk)))
                    {
                        rkPos = new RKPos(rk);
                        absoluteName = absolutePath + string.Format("{txt:{0},{1}}",
                            this.textLines.Count - 1, index + keyOffset);
                        this.owners.Add(new DefaultConnection(rk, this, ResourceDataActions.FindWrite, absoluteName));
                    }
                    rkPos.Positions.Add(this.textLines.Count - 1);
                    rkPos.Positions.Add(index + keyOffset);
                    this.oldToNewRKs.Add(rkPos);
                }
                else
                {
                    linePos -= keyLen;
                }
            }
        }
Пример #2
0
        private void SlurpReferenceRKs(TextReader reader, bool checkAltKeyFields)
        {
            const int keyLen = 8 + 1 + 8 + 1 + 16;//TTTTTTTT:GGGGGGGG:IIIIIIIIIIIIIIII
            string    absoluteName, line = reader.ReadLine();
            int       linePos = 0;
            int       index = -1;
            int       i, foundIndex, keyOffset;

            while (line != null)
            {
                this.textLines.Add(line);
                keyOffset = 4;
                index     = line.IndexOf("key:", linePos);
                if (index == -1 && checkAltKeyFields)
                {
                    index = line.IndexOf("key=\"", linePos);
                    if (index != -1)
                    {
                        keyOffset = 5;
                    }
                }
                while (index == -1)
                {
                    line = reader.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    this.textLines.Add(line);

                    linePos = 0;
                    index   = line.IndexOf("key:", linePos);
                    if (index == -1 && checkAltKeyFields)
                    {
                        index = line.IndexOf("key=\"", linePos);
                        if (index != -1)
                        {
                            keyOffset = 5;
                        }
                    }
                }
                linePos += keyOffset + keyLen;
                if (linePos > line.Length)
                {
                    line = reader.ReadLine();
                    continue;
                }

                string rkStr = line.Substring(index + keyOffset, keyLen);
                RK     rk;
                if (ParseRK(rkStr, out rk))
                {
                    RKPos rkPos = null;
                    foundIndex = -1;
                    for (i = 0; i < this.oldToNewRKs.Count && foundIndex < 0; i++)
                    {
                        rkPos = this.oldToNewRKs[i];
                        if (rkPos.OldResourceKey.Equals(rk))
                        {
                            foundIndex = i;
                        }
                    }
                    if (foundIndex == -1 && (base.validate == null || base.validate(rk)))
                    {
                        rkPos        = new RKPos(rk);
                        absoluteName = absolutePath + string.Format("{txt:{0},{1}}",
                                                                    this.textLines.Count - 1, index + keyOffset);
                        this.owners.Add(new DefaultConnection(rk, this, ResourceDataActions.FindWrite, absoluteName));
                    }
                    rkPos.Positions.Add(this.textLines.Count - 1);
                    rkPos.Positions.Add(index + keyOffset);
                    this.oldToNewRKs.Add(rkPos);
                }
                else
                {
                    linePos -= keyLen;
                }
            }
        }