internal MergeField(FieldStart fieldStart) { if (fieldStart.Equals(null)) { throw new ArgumentNullException("fieldStart"); } if (!fieldStart.FieldType.Equals(FieldType.FieldMergeField)) { throw new ArgumentException("Field start type must be FieldMergeField."); } mFieldStart = fieldStart; // Find the field separator node. mFieldSeparator = FindNextSibling(mFieldStart, NodeType.FieldSeparator); if (mFieldSeparator == null) { throw new InvalidOperationException("Cannot find field separator."); } // Find the field end node. Normally field end will always be found, but in the example document // there happens to be a paragraph break included in the hyperlink and this puts the field end // in the next paragraph. It will be much more complicated to handle fields which span several // paragraphs correctly, but in this case allowing field end to be null is enough for our purposes. mFieldEnd = FindNextSibling(mFieldSeparator, NodeType.FieldEnd); }
internal MergeField(FieldStart fieldStart) { if (fieldStart.Equals(null)) throw new ArgumentNullException("fieldStart"); if (!fieldStart.FieldType.Equals(FieldType.FieldMergeField)) throw new ArgumentException("Field start type must be FieldMergeField."); mFieldStart = fieldStart; // Find the field separator node. mFieldSeparator = fieldStart.GetField().Separator; if (mFieldSeparator == null) throw new InvalidOperationException("Cannot find field separator."); mFieldEnd = fieldStart.GetField().End; }
internal MergeField(FieldStart fieldStart) { if (fieldStart.Equals(null)) throw new ArgumentNullException("fieldStart"); if (!fieldStart.FieldType.Equals(FieldType.FieldMergeField)) throw new ArgumentException("Field start type must be FieldMergeField."); this.mFieldStart = fieldStart; // Find the field separator node. this.mFieldSeparator = FindNextSibling(this.mFieldStart, NodeType.FieldSeparator); if (this.mFieldSeparator == null) throw new InvalidOperationException("Cannot find field separator."); // Find the field end node. Normally field end will always be found, but in the example document // there happens to be a paragraph break included in the hyperlink and this puts the field end // in the next paragraph. It will be much more complicated to handle fields which span several // paragraphs correctly, but in this case allowing field end to be null is enough for our purposes. this.mFieldEnd = FindNextSibling(this.mFieldSeparator, NodeType.FieldEnd); }
internal MergeField(FieldStart fieldStart) { if (fieldStart.Equals(null)) { throw new ArgumentNullException("fieldStart"); } if (!fieldStart.FieldType.Equals(FieldType.FieldMergeField)) { throw new ArgumentException("Field start type must be FieldMergeField."); } mFieldStart = fieldStart; // Find the field separator node. mFieldSeparator = fieldStart.GetField().Separator; if (mFieldSeparator == null) { throw new InvalidOperationException("Cannot find field separator."); } mFieldEnd = fieldStart.GetField().End; }