示例#1
0
        public void DoReplace(FileData _data, IReplacer[] _replacers)
        {
            for (int index = 0; index < _data.Data.Length; )
            {
                if ((_data.Data[index] == '#') && (index + 1 < _data.Data.Length) && (_data.Data[index + 1] == '{'))
                {
                    int endIndex = index + 1;
                    while (endIndex < _data.Data.Length)
                    {
                        if (_data.Data[endIndex] == '}')
                            break;
                        endIndex++;
                    }

                    if (endIndex < _data.Data.Length)
                    {
                        int count = endIndex - index + 1;
                        char[] destination = new char[count];
                        _data.Data.CopyTo(index, destination, 0, count);

                        _data.Data.Remove(index, count);
                        _data.Data.Insert(index, ReplaceTag(destination, _replacers));
                    }
                }
                else
                {
                    index++;
                }
            }
        }
示例#2
0
        public FileData GetTemplateCopy(string _fileName)
        {
            FileData result = GetTemplate(_fileName);

            FileData newFile = new FileData();
            newFile.Data.Append(result.Data);
            return newFile;
        }
示例#3
0
        public FileData GetOutputFile(string _output)
        {
            FileData result = null;
            if (mOutputFiles.TryGetValue(_output, out result))
                return result;

            result = new FileData();
            mOutputFiles[_output] = result;

            return result;
        }
示例#4
0
        private FileData GetTemplate(string _fileName)
        {
            FileData result = null;
            if (mCache.TryGetValue(_fileName, out result))
            {
                return result;
            }

            result = new FileData();
            result.Load(_fileName);
            mCache[_fileName] = result;

            return result;
        }