示例#1
0
        public CodeLine(CodeFile file, int lineNum, string text)
        {
            _file = file;
            _lineNum = lineNum;
            _text = text;

            var match = _rxLabel.Match(_text);
            if (match.Success)
            {
                _isLabel = true;
                _label = match.Groups[1].Value.Trim();
            }
        }
示例#2
0
        public void ProcessFile(string fileName)
        {
            _fileName = fileName;

            _files.Clear();
            _lines.Clear();
            _replace.Clear();

            var mergeFileNames = ProbeEnvironment.FindLocalFiles(fileName, true).ToArray();
            if (mergeFileNames.Length == 0)
            {
                _errors.Add(new CodeError(null, "No files found."));
                return;
            }

            // Process the base file (don't end with "&")
            foreach (var baseFileName in (from f in mergeFileNames where !f.EndsWith("&") select f))
            {
                if (!string.IsNullOrEmpty(_baseFileName))
                {
                    _errors.Add(new CodeError(null, string.Format("More than one base file found.  File '{0}' is ignored.", baseFileName)));
                    continue;
                }

                _baseFileName = baseFileName;

                var file = new CodeFile(baseFileName, true);
                _files.Add(file);
                AddBaseFile(file);
            }

            // Process the local files (end with "&")
            foreach (var localFileName in (from f in mergeFileNames where f.EndsWith("&") select f))
            {
                if (!_files.Any(f => f.FileName.Equals(localFileName, StringComparison.OrdinalIgnoreCase)))
                {
                    var file = new CodeFile(localFileName, false);
                    _files.Add(file);
                    MergeLocalFile(file);
                }
            }
        }
示例#3
0
        private void MergeLocalFile(CodeFile file)
        {
            _mergeMode = MergeMode.Normal;

            using (var reader = new StreamReader(file.FileName))
            {
                if (_showMergeComments)
                {
                    _lines.Add(new CodeLine(null, 0, string.Concat("// start of local file ", file.FileName)));
                }

                int lineNum = 1;
                while (!reader.EndOfStream)
                {
                    var line = new CodeLine(file, lineNum, reader.ReadLine());
                    MergeLocalLine(line);
                    lineNum++;
                }

                if (_showMergeComments)
                {
                    _lines.Add(new CodeLine(null, 0, string.Concat("// end of local file ", file.FileName)));
                }
            }
        }
示例#4
0
        private void AddBaseFile(CodeFile file)
        {
            using (var reader = new StreamReader(file.FileName))
            {
                int lineNum = 1;
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    _lines.Add(new CodeLine(file, lineNum++, line));
                }

                if (_showMergeComments)
                {
                    _lines.Add(new CodeLine(null, 0, string.Concat("// end of base file ", file.FileName)));
                }
            }
        }