public bool Compare(XmlReader sourceReader, XmlReader changedReader, XmlWriter diffgramWriter) { if (sourceReader == null) { throw new ArgumentNullException(nameof(sourceReader)); } if (changedReader == null) { throw new ArgumentNullException(nameof(changedReader)); } try { var xmlHash = new XmlHash(this); this._xmlDiffPerf.Clean(); var tickCount = Environment.TickCount; this._sourceDoc = new XmlDiffDocument(this); this._sourceDoc.Load(sourceReader, xmlHash); this._targetDoc = new XmlDiffDocument(this); this._targetDoc.Load(changedReader, xmlHash); if (this._fragments == TriStateBool.DontKnown) { this._fragments = this._sourceDoc.IsFragment || this._targetDoc.IsFragment ? TriStateBool.Yes : TriStateBool.No; } this._xmlDiffPerf._loadTime = Environment.TickCount - tickCount; return(this.Diff(diffgramWriter)); } finally { this._sourceDoc = null; this._targetDoc = null; } }
// Loads the document from XmlReader internal virtual void Load(XmlReader reader, XmlHash xmlHash) { if (_bLoaded) { throw new InvalidOperationException("The document already contains data and should not be used again."); } try { _curLastChild = null; _xmlHash = xmlHash; LoadChildNodes(this, reader, false); ComputeHashValue(_xmlHash); _bLoaded = true; #if DEBUG if (XmlDiff.T_LoadedDoc.Enabled) { Trace.Write("\nLoaded document " + reader.BaseURI + ": \n"); Dump(); } #endif } finally { _xmlHash = null; } }
public bool Compare(XmlNode sourceNode, XmlNode changedNode, XmlWriter diffgramWriter) { if (sourceNode == null) { throw new ArgumentNullException(nameof(sourceNode)); } if (changedNode == null) { throw new ArgumentNullException(nameof(changedNode)); } try { var xmlHash = new XmlHash(this); this._xmlDiffPerf.Clean(); var tickCount = Environment.TickCount; this._sourceDoc = new XmlDiffDocument(this); this._sourceDoc.Load(sourceNode, xmlHash); this._targetDoc = new XmlDiffDocument(this); this._targetDoc.Load(changedNode, xmlHash); this._fragments = sourceNode.NodeType != XmlNodeType.Document || changedNode.NodeType != XmlNodeType.Document ? TriStateBool.Yes : TriStateBool.No; this._xmlDiffPerf._loadTime = Environment.TickCount - tickCount; return(this.Diff(diffgramWriter)); } finally { this._sourceDoc = null; this._targetDoc = null; } }
// Loads the document from XmlReader internal virtual void Load( XmlReader reader, XmlHash xmlHash ) { if ( _bLoaded ) throw new InvalidOperationException( "The document already contains data and should not be used again." ); try { _curLastChild = null; _xmlHash = xmlHash; LoadChildNodes( this, reader, false ); ComputeHashValue( _xmlHash ); _bLoaded = true; #if DEBUG if ( XmlDiff.T_LoadedDoc.Enabled ) { Trace.Write( "\nLoaded document " + reader.BaseURI + ": \n" ); Dump(); } #endif } finally { _xmlHash = null; } }
public static bool VerifySource(XmlNode node, ulong hashValue, XmlDiffOptions options) { if (node == null) { throw new ArgumentNullException(nameof(node)); } var hash = new XmlHash().ComputeHash(node, options); return((long)hashValue == (long)hash); }
// Loads the document from XmlNode internal virtual void Load(XmlNode node, XmlHash xmlHash) { if (_bLoaded) { throw new InvalidOperationException("The document already contains data and should not be used again."); } if (node.NodeType == XmlNodeType.Attribute || node.NodeType == XmlNodeType.Entity || node.NodeType == XmlNodeType.Notation || node.NodeType == XmlNodeType.Whitespace) { throw new ArgumentException("Invalid node type."); } try { _curLastChild = null; _xmlHash = xmlHash; if (node.NodeType == XmlNodeType.Document || node.NodeType == XmlNodeType.DocumentFragment) { LoadChildNodes(this, node); ComputeHashValue(_xmlHash); } else { int childPos = 0; XmlDiffNode rootNode = LoadNode(node, ref childPos); if (rootNode != null) { InsertChildNodeAfter(null, rootNode); _hashValue = rootNode.HashValue; } } _bLoaded = true; #if DEBUG if (XmlDiff.T_LoadedDoc.Enabled) { Trace.Write("\nLoaded document " + node.BaseURI + ": \n"); Dump(); } #endif } finally { _xmlHash = null; } }
internal virtual void Load(XmlReader reader, XmlHash xmlHash) { if (this._bLoaded) throw new InvalidOperationException("The document already contains data and should not be used again."); try { this._curLastChild = (XmlDiffNode) null; this._xmlHash = xmlHash; this.LoadChildNodes((XmlDiffParentNode) this, reader, false); this.ComputeHashValue(this._xmlHash); this._bLoaded = true; } finally { this._xmlHash = (XmlHash) null; } }
internal virtual void Load(XmlNode node, XmlHash xmlHash) { if (this._bLoaded) throw new InvalidOperationException("The document already contains data and should not be used again."); if (node.NodeType != XmlNodeType.Attribute && node.NodeType != XmlNodeType.Entity && node.NodeType != XmlNodeType.Notation) { if (node.NodeType != XmlNodeType.Whitespace) { try { this._curLastChild = (XmlDiffNode) null; this._xmlHash = xmlHash; if (node.NodeType == XmlNodeType.Document || node.NodeType == XmlNodeType.DocumentFragment) { this.LoadChildNodes((XmlDiffParentNode) this, node); this.ComputeHashValue(this._xmlHash); } else { var childPosition = 0; var newChildNode = this.LoadNode(node, ref childPosition); if (newChildNode != null) { this.InsertChildNodeAfter((XmlDiffNode) null, newChildNode); this._hashValue = newChildNode.HashValue; } } this._bLoaded = true; return; } finally { this._xmlHash = (XmlHash) null; } } } throw new ArgumentException("Invalid node type."); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue(XmlHash xmlHash) { Debug.Assert(_hashValue == 0); _hashValue = xmlHash.HashAttribute(_localName, _prefix, _ns, _value); }
// Methods // computes the hash value of the node and saves it into the _hashValue field internal override void ComputeHashValue(XmlHash xmlHash) { Debug.Assert(_hashValue == 0); _hashValue = xmlHash.HashDocumentType(_name, _publicId, _systemId, _subset); }
// Methods // computes the hash value of the node and saves it into the _hashValue field internal override void ComputeHashValue(XmlHash xmlHash) { Debug.Assert(false, "This method should bever be called."); }
internal override void ComputeHashValue(XmlHash xmlHash) { }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue( XmlHash xmlHash ) { Debug.Assert( _hashValue == 0 ); _hashValue = xmlHash.HashAttribute( _localName, _prefix, _ns, _value ); }
internal override void ComputeHashValue(XmlHash xmlHash) { this._hashValue = xmlHash.HashNamespace(this._prefix, this._namespaceURI); }
internal override void ComputeHashValue(XmlHash xmlHash) { this._hashValue = xmlHash.HashER(this._name); }
internal override void ComputeHashValue(XmlHash xmlHash) { this._hashValue = xmlHash.ComputeHashXmlDiffDocument(this); }
internal override void ComputeHashValue(XmlHash xmlHash) { this._hashValue = xmlHash.HashXmlDeclaration(this._value); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue(XmlHash xmlHash) { Debug.Assert(_hashValue == 0); _hashValue = xmlHash.HashER(_name); }
internal override void ComputeHashValue(XmlHash xmlHash) { this._hashValue = xmlHash.HashPI(this.Name, this.Value); }
/// <include file='doc\XmlDiff.uex' path='docs/doc[@for="XmlDiff.Compare6"]/*' /> /// <summary> /// Compares two XML nodes. /// If the diffgramWriter parameter is not null it will contain the list of changes /// between the two XML documents/fragments (diffgram). /// </summary> /// <param name="sourceNode">Original XML node</param> /// <param name="changedNode">Changed XML node</param> /// <param name="diffgramWriter">XmlWriter object for returning the list of changes (diffgram).</param> /// <returns>True, if the documents/fragments are identical.</returns> public bool Compare( XmlNode sourceNode, XmlNode changedNode, XmlWriter diffgramWriter ) { if ( sourceNode == null ) throw new ArgumentNullException( "sourceNode" ); if ( changedNode == null ) throw new ArgumentNullException( "changedNode" ); try { XmlHash xmlHash = new XmlHash( this ); #if MEASURE_PERF _xmlDiffPerf.Clean(); int startTickCount = Environment.TickCount; #endif // load source document _sourceDoc = new XmlDiffDocument( this ); _sourceDoc.Load( sourceNode, xmlHash ); #if DEBUG Trace.WriteLineIf( T_Phases.Enabled, "* Source document loaded: " + _sourceDoc.NodesCount + " nodes." ); #endif // load target document _targetDoc = new XmlDiffDocument( this ); _targetDoc.Load( changedNode, xmlHash ); _fragments = ( sourceNode.NodeType != XmlNodeType.Document || changedNode.NodeType != XmlNodeType.Document ) ? TriStateBool.Yes : TriStateBool.No; #if DEBUG Trace.WriteLineIf( T_Phases.Enabled, "* Target document loaded: " + _targetDoc.NodesCount + " nodes." ); #endif #if MEASURE_PERF _xmlDiffPerf._loadTime = Environment.TickCount - startTickCount; #endif // compare return Diff( diffgramWriter ); } finally { _sourceDoc = null; _targetDoc = null; } }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal abstract void ComputeHashValue( XmlHash xmlHash );
// Loads the document from XmlNode internal virtual void Load( XmlNode node, XmlHash xmlHash ) { if ( _bLoaded ) throw new InvalidOperationException( "The document already contains data and should not be used again." ); if ( node.NodeType == XmlNodeType.Attribute || node.NodeType == XmlNodeType.Entity || node.NodeType == XmlNodeType.Notation || node.NodeType == XmlNodeType.Whitespace ) { throw new ArgumentException( "Invalid node type." ); } try { _curLastChild = null; _xmlHash = xmlHash; if ( node.NodeType == XmlNodeType.Document || node.NodeType == XmlNodeType.DocumentFragment ) { LoadChildNodes( this, node ); ComputeHashValue( _xmlHash ); } else { int childPos = 0; XmlDiffNode rootNode = LoadNode( node, ref childPos ); if ( rootNode != null ) { InsertChildNodeAfter( null, rootNode ); _hashValue = rootNode.HashValue; } } _bLoaded = true; #if DEBUG if ( XmlDiff.T_LoadedDoc.Enabled ) { Trace.Write( "\nLoaded document " + node.BaseURI + ": \n" ); Dump(); } #endif } finally { _xmlHash = null; } }
/// <include file='doc\XmlDiff.uex' path='docs/doc[@for="XmlDiff.VerifySource"]/*' /> /// <summary> /// Given a diffgram, this method verifies whether the given document/node is the original /// source document/node for the diffgram. /// </summary> /// <param name="node">Document/node to be verified.</param> /// <param name="hashValue">Value of the 'srcDocHash' attribute of the 'xd:xmldiff' element in diffgram. /// This is the hash value of the original source document. The document/node is verified if it yields /// the same hash value.</param> /// <param name="options">XmlDiff options selected when the document/node was compared. The hash value /// of the document/node depends on these options.</param> /// <returns>True if the given document is the original source document for the diffgram.</returns> static public bool VerifySource( XmlNode node, ulong hashValue, XmlDiffOptions options ) { if ( node == null ) throw new ArgumentNullException( "node" ); ulong computedHashValue = new XmlHash().ComputeHash( node, options ); return hashValue == computedHashValue; }
// Methods // computes the hash value of the node and saves it into the _hashValue field internal override void ComputeHashValue( XmlHash xmlHash ) { Debug.Assert( false, "This method should bever be called." ); }
internal override void ComputeHashValue(XmlHash xmlHash) { this._hashValue = xmlHash.HashAttribute(this._localName, this._prefix, this._ns, this._value); }
// Methods // computes the hash value of the node and saves it into the _hashValue field internal override void ComputeHashValue( XmlHash xmlHash ) { Debug.Assert( _hashValue == 0 ); _hashValue = xmlHash.HashXmlDeclaration( _value ); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue( XmlHash xmlHash ) { Debug.Assert( _hashValue == 0 ); _hashValue = xmlHash.HashCharacterNode( (XmlNodeType)(int)_nodeType, _value ); }
// Methods // computes the hash value of the node and saves it into the _hashValue field internal override void ComputeHashValue( XmlHash xmlHash ) { Debug.Assert( _hashValue == 0 ); _hashValue = xmlHash.HashDocumentType( _name, _publicId, _systemId, _subset ); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal abstract void ComputeHashValue(XmlHash xmlHash);
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue( XmlHash xmlHash ) { Debug.Assert( _hashValue == 0 ); _hashValue = xmlHash.ComputeHashXmlDiffElement( this ); }
// Methods // computes the hash value of the node and saves it into the _hashValue field internal override void ComputeHashValue(XmlHash xmlHash) { Debug.Assert(_hashValue == 0); _hashValue = xmlHash.HashXmlDeclaration(_value); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue( XmlHash xmlHash ) { Debug.Assert( _hashValue == 0 ); _hashValue = xmlHash.HashER( _name ); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue(XmlHash xmlHash) { Debug.Assert(_hashValue == 0); _hashValue = xmlHash.ComputeHashXmlDiffElement(this); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue( XmlHash xmlHash ) { Debug.Assert( _hashValue == 0 ); _hashValue = xmlHash.HashNamespace( _prefix, _namespaceURI ); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue(XmlHash xmlHash) { Debug.Assert(_hashValue == 0); _hashValue = xmlHash.HashNamespace(_prefix, _namespaceURI); }
internal override void ComputeHashValue(XmlHash xmlHash) { this._hashValue = xmlHash.HashDocumentType(this._name, this._publicId, this._systemId, this._subset); }
// Methods // computes hash value of the node and stores it in the _hashValue variable internal override void ComputeHashValue(XmlHash xmlHash) { Debug.Assert(_hashValue == 0); _hashValue = xmlHash.HashCharacterNode((XmlNodeType)(int)_nodeType, _value); }
internal override void ComputeHashValue(XmlHash xmlHash) { this._hashValue = xmlHash.HashCharacterNode((XmlNodeType)this._nodeType, this._value); }