Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Serialization / System / Xml / XmlDictionary.cs / 1 / XmlDictionary.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Xml { using System; using System.IO; using System.Xml; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Runtime.Serialization; public class XmlDictionary : IXmlDictionary { static IXmlDictionary empty; Dictionarylookup; XmlDictionaryString[] strings; int nextId; static public IXmlDictionary Empty { get { if (empty == null) empty = new EmptyDictionary(); return empty; } } public XmlDictionary() { this.lookup = new Dictionary (); this.strings = null; this.nextId = 0; } public XmlDictionary(int capacity) { this.lookup = new Dictionary (capacity); this.strings = new XmlDictionaryString[capacity]; this.nextId = 0; } public virtual XmlDictionaryString Add(string value) { XmlDictionaryString str; if (!this.lookup.TryGetValue(value, out str)) { if (this.strings == null) { this.strings = new XmlDictionaryString[4]; } else if (this.nextId == this.strings.Length) { int newSize = this.nextId * 2; if (newSize == 0) newSize = 4; Array.Resize(ref this.strings, newSize); } str = new XmlDictionaryString(this, value, this.nextId); this.strings[this.nextId] = str; this.lookup.Add(value, str); this.nextId++; } return str; } public virtual bool TryLookup(string value, out XmlDictionaryString result) { return this.lookup.TryGetValue(value, out result); } public virtual bool TryLookup(int key, out XmlDictionaryString result) { if (key < 0 || key >= this.nextId) { result = null; return false; } result = this.strings[key]; return true; } public virtual bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result) { if (value == null) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value")); if (value.Dictionary != this) { result = null; return false; } result = value; return true; } class EmptyDictionary : IXmlDictionary { public bool TryLookup(string value, out XmlDictionaryString result) { result = null; return false; } public bool TryLookup(int key, out XmlDictionaryString result) { result = null; return false; } public bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result) { result = null; return false; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ResolveResponse.cs
- DataObjectAttribute.cs
- OleDbDataAdapter.cs
- ExecutedRoutedEventArgs.cs
- CommandManager.cs
- HtmlContainerControl.cs
- EventLogInternal.cs
- BamlLocalizabilityResolver.cs
- SolidColorBrush.cs
- HttpCookiesSection.cs
- AssociationEndMember.cs
- CodeMethodInvokeExpression.cs
- PerfCounters.cs
- LicenseManager.cs
- ButtonAutomationPeer.cs
- Form.cs
- ContentElementAutomationPeer.cs
- PersonalizationProviderCollection.cs
- MainMenu.cs
- ConfigXmlSignificantWhitespace.cs
- ScriptingWebServicesSectionGroup.cs
- TableCell.cs
- DBSchemaTable.cs
- AdPostCacheSubstitution.cs
- MouseBinding.cs
- RequestCacheValidator.cs
- ActivityExecutorDelegateInfo.cs
- BaseInfoTable.cs
- DynamicPropertyReader.cs
- FragmentQueryProcessor.cs
- SvcFileManager.cs
- SqlTriggerContext.cs
- BinaryObjectReader.cs
- StreamProxy.cs
- SystemKeyConverter.cs
- Color.cs
- ManagementPath.cs
- SmtpAuthenticationManager.cs
- HttpResponseHeader.cs
- Monitor.cs
- XmlBinaryReader.cs
- ParseChildrenAsPropertiesAttribute.cs
- DependencyPropertyHelper.cs
- WebScriptClientGenerator.cs
- XmlMembersMapping.cs
- storepermissionattribute.cs
- EncoderNLS.cs
- StorageEntitySetMapping.cs
- WindowsListViewItemStartMenu.cs
- SqlParameter.cs
- OleDbInfoMessageEvent.cs
- DictionaryEntry.cs
- SourceCollection.cs
- DataGridViewCellLinkedList.cs
- MetafileHeader.cs
- InternalRelationshipCollection.cs
- BezierSegment.cs
- SiteMapPath.cs
- WebCategoryAttribute.cs
- ClrPerspective.cs
- InstanceKeyCollisionException.cs
- TextOutput.cs
- AddInAdapter.cs
- ByteAnimation.cs
- PaperSize.cs
- RtfControlWordInfo.cs
- BaseCodeDomTreeGenerator.cs
- infer.cs
- TriggerBase.cs
- ICollection.cs
- Substitution.cs
- BitmapCacheBrush.cs
- InvalidDataContractException.cs
- Win32.cs
- DiscoveryClientProtocol.cs
- PackWebRequest.cs
- EdgeModeValidation.cs
- SoapObjectWriter.cs
- MsmqChannelFactoryBase.cs
- CqlLexer.cs
- LiteralTextParser.cs
- XPathSelfQuery.cs
- DataGridTextBox.cs
- SafeNativeMemoryHandle.cs
- XmlSchemaAppInfo.cs
- NetworkCredential.cs
- PeerInvitationResponse.cs
- XmlToDatasetMap.cs
- CodeSnippetCompileUnit.cs
- ErrorView.xaml.cs
- ConfigurationFileMap.cs
- SmtpTransport.cs
- SmtpNtlmAuthenticationModule.cs
- RequiredFieldValidator.cs
- InfocardChannelParameter.cs
- HTMLTextWriter.cs
- TableCell.cs
- RawUIStateInputReport.cs
- ToolStripButton.cs
- Calendar.cs