public void AddNamespace(string prefix, Uri uri) { OffsetMapping mapping = new OffsetMapping(prefix, uri, this._offset); if (!this._prefixes.ContainsKey(uri.GetEnhancedHashCode())) this._prefixes.Add(uri.GetEnhancedHashCode(), new List<OffsetMapping>()); if (this._uris.ContainsKey(prefix)) { //Is it defined at the current offset level? if (this._uris[prefix].Any(m => m.Offset == this._offset)) { //If it is then we override it this._uris[prefix].RemoveAll(m => m.Offset == this._offset); this._prefixes[uri.GetEnhancedHashCode()].RemoveAll(m => m.Offset == this._offset); this._uris[prefix].Add(mapping); this._prefixes[uri.GetEnhancedHashCode()].Add(mapping); this.OnNamespaceModified(prefix, uri); } else { //If not we simply add it this._uris[prefix].Add(mapping); this._prefixes[uri.GetEnhancedHashCode()].Add(mapping); this.OnNamespaceAdded(prefix, uri); } } else { //Not yet defined so add it this._uris.Add(prefix, new List<OffsetMapping>()); this._uris[prefix].Add(mapping); this._prefixes[uri.GetEnhancedHashCode()].Add(mapping); this.OnNamespaceAdded(prefix, uri); } }
public void AddNamespace(string prefix, Uri uri) { OffsetMapping mapping = new OffsetMapping(prefix, uri, this._offset); if (!this._prefixes.ContainsKey(uri.GetEnhancedHashCode())) { this._prefixes.Add(uri.GetEnhancedHashCode(), new List <OffsetMapping>()); } if (this._uris.ContainsKey(prefix)) { //Is it defined at the current offset level? if (this._uris[prefix].Any(m => m.Offset == this._offset)) { //If it is then we override it this._uris[prefix].RemoveAll(m => m.Offset == this._offset); this._prefixes[uri.GetEnhancedHashCode()].RemoveAll(m => m.Offset == this._offset); this._uris[prefix].Add(mapping); this._prefixes[uri.GetEnhancedHashCode()].Add(mapping); this.OnNamespaceModified(prefix, uri); } else { //If not we simply add it this._uris[prefix].Add(mapping); this._prefixes[uri.GetEnhancedHashCode()].Add(mapping); this.OnNamespaceAdded(prefix, uri); } } else { //Not yet defined so add it this._uris.Add(prefix, new List <OffsetMapping>()); this._uris[prefix].Add(mapping); this._prefixes[uri.GetEnhancedHashCode()].Add(mapping); this.OnNamespaceAdded(prefix, uri); } }