private void ComputeHashXmlDiffChildren(HashAlgorithm ha, XmlDiffParentNode parent) { var i = 0; if (this._bIgnoreChildOrder) { ulong u = 0; for (var xmlDiffNode = parent.FirstChildNode; xmlDiffNode != null; xmlDiffNode = xmlDiffNode._nextSibling) { u += xmlDiffNode.HashValue; ++i; } ha.AddULong(u); } else { for (var xmlDiffNode = parent.FirstChildNode; xmlDiffNode != null; xmlDiffNode = xmlDiffNode._nextSibling) { ha.AddULong(xmlDiffNode.HashValue); ++i; } } if (i == 0) { return; } ha.AddInt(i); }
private void ComputeHashXmlDiffAttributes(HashAlgorithm ha, XmlDiffElement el) { var i = 0; ulong u = 0; for (var attributeOrNamespace = el._attributes; attributeOrNamespace != null; attributeOrNamespace = (XmlDiffAttributeOrNamespace)attributeOrNamespace._nextSibling) { u += attributeOrNamespace.HashValue; ++i; } if (i <= 0) { return; } ha.AddULong(u); ha.AddInt(i); }
private void ComputeHashXmlDiffAttributes(HashAlgorithm ha, XmlDiffElement el) { int attrCount = 0; ulong attrHashAll = 0; XmlDiffAttributeOrNamespace curAttrOrNs = el._attributes; while (curAttrOrNs != null) { attrHashAll += curAttrOrNs.HashValue; attrCount++; curAttrOrNs = (XmlDiffAttributeOrNamespace)curAttrOrNs._nextSibling; } if (attrCount > 0) { ha.AddULong(attrHashAll); ha.AddInt(attrCount); } }
private void ComputeHashXmlDiffChildren(HashAlgorithm ha, XmlDiffParentNode parent) { int childrenCount = 0; if (_bIgnoreChildOrder) { ulong totalHash = 0; XmlDiffNode curChild = parent.FirstChildNode; while (curChild != null) { Debug.Assert(!(curChild is XmlDiffAttributeOrNamespace)); Debug.Assert(curChild.HashValue != 0); totalHash += curChild.HashValue; childrenCount++; curChild = curChild._nextSibling; } ha.AddULong(totalHash); } else { XmlDiffNode curChild = parent.FirstChildNode; while (curChild != null) { Debug.Assert(!(curChild is XmlDiffAttributeOrNamespace)); Debug.Assert(curChild.HashValue != 0); ha.AddULong(curChild.HashValue); childrenCount++; curChild = curChild._nextSibling; } } if (childrenCount != 0) { ha.AddInt(childrenCount); } }
private void ComputeHashXmlChildren(HashAlgorithm ha, XmlNode parent) { XmlElement el = parent as XmlElement; if (el != null) { ulong attrHashSum = 0; int attrsCount = 0; XmlAttributeCollection attrs = ((XmlElement)parent).Attributes; for (int i = 0; i < attrs.Count; i++) { XmlAttribute attr = (XmlAttribute)attrs.Item(i); ulong hashValue = 0; // default namespace def if (attr.LocalName == "xmlns" && attr.Prefix == string.Empty) { if (_bIgnoreNamespaces) { continue; } hashValue = HashNamespace(string.Empty, attr.Value); } // namespace def else if (attr.Prefix == "xmlns") { if (_bIgnoreNamespaces) { continue; } hashValue = HashNamespace(attr.LocalName, attr.Value); } // attribute else { if (_bIgnoreWhitespace) { hashValue = HashAttribute(attr.LocalName, attr.Prefix, attr.NamespaceURI, XmlDiff.NormalizeText(attr.Value)); } else { hashValue = HashAttribute(attr.LocalName, attr.Prefix, attr.NamespaceURI, attr.Value); } } Debug.Assert(hashValue != 0); attrsCount++; attrHashSum += hashValue; } if (attrsCount != 0) { ha.AddULong(attrHashSum); ha.AddInt(attrsCount); } } int childrenCount = 0; if (_bIgnoreChildOrder) { ulong totalHashSum = 0; XmlNode curChild = parent.FirstChild; while (curChild != null) { ulong hashValue = ComputeHashXmlNode(curChild); if (hashValue != 0) { totalHashSum += hashValue; childrenCount++; } curChild = curChild.NextSibling; } ha.AddULong(totalHashSum); } else { XmlNode curChild = parent.FirstChild; while (curChild != null) { ulong hashValue = ComputeHashXmlNode(curChild); if (hashValue != 0) { ha.AddULong(hashValue); childrenCount++; } curChild = curChild.NextSibling; } } if (childrenCount != 0) { ha.AddInt(childrenCount); } }
private void ComputeHashXmlChildren(HashAlgorithm ha, XmlNode parent) { if (parent is XmlElement) { ulong u = 0; var i = 0; var attributes = parent.Attributes; for (var index = 0; index < attributes.Count; ++index) { var xmlAttribute = (XmlAttribute)attributes.Item(index); ulong num; if (xmlAttribute.LocalName == "xmlns" && xmlAttribute.Prefix == string.Empty) { if (!this._bIgnoreNamespaces) { num = this.HashNamespace(string.Empty, xmlAttribute.Value); } else { continue; } } else if (xmlAttribute.Prefix == "xmlns") { if (!this._bIgnoreNamespaces) { num = this.HashNamespace(xmlAttribute.LocalName, xmlAttribute.Value); } else { continue; } } else { num = !this._bIgnoreWhitespace ? this.HashAttribute(xmlAttribute.LocalName, xmlAttribute.Prefix, xmlAttribute.NamespaceURI, xmlAttribute.Value) : this.HashAttribute(xmlAttribute.LocalName, xmlAttribute.Prefix, xmlAttribute.NamespaceURI, XmlDiff.NormalizeText(xmlAttribute.Value)); } ++i; u += num; } if (i != 0) { ha.AddULong(u); ha.AddInt(i); } } var i1 = 0; if (this._bIgnoreChildOrder) { ulong u = 0; for (var node = parent.FirstChild; node != null; node = node.NextSibling) { var hashXmlNode = this.ComputeHashXmlNode(node); if (hashXmlNode != 0UL) { u += hashXmlNode; ++i1; } } ha.AddULong(u); } else { for (var node = parent.FirstChild; node != null; node = node.NextSibling) { var hashXmlNode = this.ComputeHashXmlNode(node); if (hashXmlNode != 0UL) { ha.AddULong(hashXmlNode); ++i1; } } } if (i1 == 0) { return; } ha.AddInt(i1); }
private void ComputeHashXmlChildren( HashAlgorithm ha, XmlNode parent ) { XmlElement el = parent as XmlElement; if ( el != null ) { ulong attrHashSum = 0; int attrsCount = 0; XmlAttributeCollection attrs = ((XmlElement)parent).Attributes; for ( int i = 0; i < attrs.Count; i++ ) { XmlAttribute attr = (XmlAttribute)attrs.Item(i); ulong hashValue = 0; // default namespace def if ( attr.LocalName == "xmlns" && attr.Prefix == string.Empty ) { if ( _bIgnoreNamespaces ) { continue; } hashValue = HashNamespace( string.Empty, attr.Value ); } // namespace def else if ( attr.Prefix == "xmlns" ) { if ( _bIgnoreNamespaces ) { continue; } hashValue = HashNamespace( attr.LocalName, attr.Value ); } // attribute else { if ( _bIgnoreWhitespace ) hashValue = HashAttribute( attr.LocalName, attr.Prefix, attr.NamespaceURI, XmlDiff.NormalizeText( attr.Value ) ); else hashValue = HashAttribute( attr.LocalName, attr.Prefix, attr.NamespaceURI, attr.Value ); } Debug.Assert( hashValue != 0 ); attrsCount++; attrHashSum += hashValue; } if ( attrsCount != 0 ) { ha.AddULong( attrHashSum ); ha.AddInt( attrsCount ); } } int childrenCount = 0; if ( _bIgnoreChildOrder ) { ulong totalHashSum = 0; XmlNode curChild = parent.FirstChild; while ( curChild != null ) { ulong hashValue = ComputeHashXmlNode( curChild ); if ( hashValue != 0 ) { totalHashSum += hashValue; childrenCount++; } curChild = curChild.NextSibling; } ha.AddULong( totalHashSum ); } else { XmlNode curChild = parent.FirstChild; while ( curChild != null ) { ulong hashValue = ComputeHashXmlNode( curChild ); if ( hashValue != 0 ) { ha.AddULong( hashValue ); childrenCount++; } curChild = curChild.NextSibling; } } if ( childrenCount != 0 ) ha.AddInt( childrenCount ); }
private void ComputeHashXmlDiffChildren( HashAlgorithm ha, XmlDiffParentNode parent ) { int childrenCount = 0; if ( _bIgnoreChildOrder ) { ulong totalHash = 0; XmlDiffNode curChild = parent.FirstChildNode; while ( curChild != null ) { Debug.Assert( !( curChild is XmlDiffAttributeOrNamespace ) ); Debug.Assert ( curChild.HashValue != 0 ); totalHash += curChild.HashValue; childrenCount++; curChild = curChild._nextSibling; } ha.AddULong( totalHash ); } else { XmlDiffNode curChild = parent.FirstChildNode; while ( curChild != null ) { Debug.Assert( !( curChild is XmlDiffAttributeOrNamespace ) ); Debug.Assert ( curChild.HashValue != 0 ); ha.AddULong( curChild.HashValue ); childrenCount++; curChild = curChild._nextSibling; } } if ( childrenCount != 0 ) ha.AddInt( childrenCount ); }
private void ComputeHashXmlDiffAttributes( HashAlgorithm ha, XmlDiffElement el ) { int attrCount = 0; ulong attrHashAll = 0; XmlDiffAttributeOrNamespace curAttrOrNs = el._attributes; while ( curAttrOrNs != null ) { attrHashAll += curAttrOrNs.HashValue; attrCount++; curAttrOrNs = (XmlDiffAttributeOrNamespace)curAttrOrNs._nextSibling; } if ( attrCount > 0 ) { ha.AddULong( attrHashAll ); ha.AddInt( attrCount ); } }