/// <summary>
        ///     Merge the template with the current document.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="values">The values of the template.</param>
        public void Merge(TemplateReference template, IEnumerable <Patent> values)
        {
            var writingProcessor = new WritingProcessor(new IWriter <Patent>[]
            {
                new ClaimsWriter(), new FamilyWriter(), new LinkWriter(),
                new PictureWriter(), new SimpleTextWriter()
            });

            foreach (var value in values)
            {
                writingProcessor.Write(template, value);
            }
        }
        /// <summary>
        ///     Writes the value in the document using the specified template.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="value">The value.</param>
        public void Write(TemplateReference template, Patent value)
        {
            if (template == null)
            {
                throw new ArgumentNullException(nameof(template));
            }

            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            _target.UndoRecord.StartCustomRecord($"POT {value.PublicationNumber}");

            try
            {
                InsertTemplate(template.Path);
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException("template insertion failure", exception);
            }

            foreach (Field current in _target.ActiveDocument.Fields)
            {
                if (!TryExtractCode(current, out var code))
                {
                    continue;
                }

                try
                {
                    WriteValue(code, value, current.Result);
                }
                catch
                {
                    // todo: logging
                }
                finally
                {
                    current.Delete();
                }
            }

            _target.UndoRecord.EndCustomRecord();
        }