Esempio n. 1
0
        public DocProcessor(string fileName, ReferenceCollection refs, ReferenceOrder order)
        {
            if (fileName.IsNullOrBlank()) throw new ArgumentException("fileName");
            if (refs.IsNullOrEmpty()) throw new ArgumentException("refs");

            _word = new Application {Visible = false};
            _refs = refs;
            _order = order;

            try
            {
                _doc = _word.Documents.Open(fileName, ReadOnly: true);
            }
            catch(Exception ex)
            {
                throw new Exception("Error opening Word document", ex);
            }

            _rep = new ReferenceReplacer(_doc.Content.Text, ref _refs, _order);
        }