Diffgram.cs
上传用户:hbhltzc
上传日期:2022-06-04
资源大小:1925k
文件大小:2k
源码类别:

xml/soap/webservice

开发平台:

Visual C++

  1. //------------------------------------------------------------------------------
  2. // <copyright file="Diffgram.cs" company="Microsoft">
  3. //     Copyright (c) Microsoft Corporation.  All rights reserved.
  4. // </copyright>                                                                
  5. //------------------------------------------------------------------------------
  6. using System;
  7. using System.Xml;
  8. using System.Diagnostics;
  9. namespace Microsoft.XmlDiffPatch
  10. {
  11. //////////////////////////////////////////////////////////////////
  12. // Diffgram
  13. //
  14. internal class Diffgram : DiffgramParentOperation
  15. {
  16. // Fields
  17.     XmlDiff _xmlDiff;
  18.     
  19.     OperationDescriptor _descriptors;
  20. // Constructor
  21.     internal Diffgram( XmlDiff xmlDiff ) : base( 0 )
  22.     {
  23.         _xmlDiff = xmlDiff;
  24.     }
  25. // Properties
  26.     internal override XmlDiffOperation Operation {
  27.         get {
  28.             return XmlDiffOperation.Undefined;
  29.         }
  30.     }
  31. // Methods
  32.     internal void AddDescriptor( OperationDescriptor desc )
  33.     {
  34.         desc._nextDescriptor = _descriptors;
  35.         _descriptors = desc;
  36.     }
  37.     internal override void WriteTo( XmlWriter xmlWriter, XmlDiff xmlDiff ) {
  38.         _xmlDiff = xmlDiff;
  39.         WriteTo( xmlWriter );
  40.     }
  41.     internal void WriteTo( XmlWriter xmlWriter )
  42.     {
  43.         Debug.Assert( _xmlDiff._fragments != TriStateBool.DontKnown );
  44.         xmlWriter.WriteStartDocument();
  45.         xmlWriter.WriteStartElement( XmlDiff.Prefix, "xmldiff", XmlDiff.NamespaceUri );
  46.         xmlWriter.WriteAttributeString( "version", "1.0" );
  47.         xmlWriter.WriteAttributeString( "srcDocHash", _xmlDiff._sourceDoc.HashValue.ToString() );
  48.         xmlWriter.WriteAttributeString( "options", _xmlDiff.GetXmlDiffOptionsString() );
  49.         xmlWriter.WriteAttributeString( "fragments", ( _xmlDiff._fragments == TriStateBool.Yes ) ? "yes" : "no" ) ;
  50.         WriteChildrenTo( xmlWriter, _xmlDiff );
  51.         OperationDescriptor curOD = _descriptors;
  52.         while ( curOD != null )
  53.         {
  54.             curOD.WriteTo( xmlWriter );
  55.             curOD = curOD._nextDescriptor;
  56.         }
  57.         xmlWriter.WriteEndElement(); 
  58.         xmlWriter.WriteEndDocument();
  59.     }
  60. }
  61. }