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

xml/soap/webservice

开发平台:

Visual C++

  1. //------------------------------------------------------------------------------
  2. // <copyright file="OperationDescriptor.cs" company="Microsoft">
  3. //     Copyright (c) Microsoft Corporation.  All rights reserved.
  4. // </copyright>                                                                
  5. //------------------------------------------------------------------------------
  6. using System;
  7. using System.Diagnostics;
  8. using System.Xml;
  9. namespace Microsoft.XmlDiffPatch
  10. {
  11. //////////////////////////////////////////////////////////////////
  12. // OperationDescriptor
  13. //
  14. internal abstract class OperationDescriptor
  15. {
  16. // Fields
  17.     protected ulong _operationID;
  18.     internal OperationDescriptor _nextDescriptor;
  19. // Constructor
  20. internal OperationDescriptor( ulong opid )
  21. {
  22.         Debug.Assert( opid > 0 );
  23.         _operationID = opid;
  24. }
  25. // Properties
  26.     internal abstract string Type { get; }
  27. // Methods
  28.     internal virtual void WriteTo( XmlWriter xmlWriter )
  29.     {
  30.         xmlWriter.WriteStartElement( XmlDiff.Prefix, "descriptor", XmlDiff.NamespaceUri );
  31.         xmlWriter.WriteAttributeString( "opid", _operationID.ToString() );
  32.         xmlWriter.WriteAttributeString( "type", Type );
  33.         xmlWriter.WriteEndElement();
  34.     }
  35. }
  36. //////////////////////////////////////////////////////////////////
  37. // OperationDescMove
  38. //
  39. internal class OperationDescrMove : OperationDescriptor
  40. {
  41. // Constructor
  42. internal OperationDescrMove( ulong opid ) : base ( opid )
  43. {
  44. }
  45. // Properties
  46.     internal override string Type { get { return "move"; } }
  47. }
  48. //////////////////////////////////////////////////////////////////
  49. // OperationDescNamespaceChange
  50. //
  51. internal class OperationDescrNamespaceChange : OperationDescriptor
  52. {
  53. // Fields
  54.     DiffgramGenerator.NamespaceChange _nsChange;
  55.     
  56. // Constructor
  57. internal OperationDescrNamespaceChange( DiffgramGenerator.NamespaceChange nsChange ) 
  58.         : base ( nsChange._opid )
  59. {
  60.         _nsChange = nsChange;
  61. }
  62. // Properties
  63.     internal override string Type { get { return "namespace change"; } }
  64. // Methods
  65.     internal override void WriteTo( XmlWriter xmlWriter )
  66.     {
  67.         xmlWriter.WriteStartElement( XmlDiff.Prefix, "descriptor", XmlDiff.NamespaceUri );
  68.         xmlWriter.WriteAttributeString( "opid", _operationID.ToString() );
  69.         xmlWriter.WriteAttributeString( "type", Type );
  70.         xmlWriter.WriteAttributeString( "prefix", _nsChange._prefix );
  71.         xmlWriter.WriteAttributeString( "oldNs", _nsChange._oldNS );
  72.         xmlWriter.WriteAttributeString( "newNs", _nsChange._newNS );
  73.         xmlWriter.WriteEndElement();
  74.     }
  75. }
  76. //////////////////////////////////////////////////////////////////
  77. // OperationDescPrefixChange
  78. //
  79. internal class OperationDescrPrefixChange : OperationDescriptor
  80. {
  81. // Fields
  82.     DiffgramGenerator.PrefixChange _prefixChange;
  83.     
  84. // Constructor
  85. internal OperationDescrPrefixChange( DiffgramGenerator.PrefixChange prefixChange ) 
  86.         : base ( prefixChange._opid )
  87. {
  88.         _prefixChange = prefixChange;
  89. }
  90. // Properties
  91.     internal override string Type { get { return "prefix change"; } }
  92. // Methods
  93.     internal override void WriteTo( XmlWriter xmlWriter )
  94.     {
  95.         xmlWriter.WriteStartElement( XmlDiff.Prefix, "descriptor", XmlDiff.NamespaceUri );
  96.         xmlWriter.WriteAttributeString( "opid", _operationID.ToString() );
  97.         xmlWriter.WriteAttributeString( "type", Type );
  98.         xmlWriter.WriteAttributeString( "ns", _prefixChange._NS );
  99.         xmlWriter.WriteAttributeString( "oldPrefix", _prefixChange._oldPrefix );
  100.         xmlWriter.WriteAttributeString( "newPrefix", _prefixChange._newPrefix );
  101.         xmlWriter.WriteEndElement();
  102.     }
  103. }
  104. }