Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Xml / XmlDictionary.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ColorMap.cs
- ConstNode.cs
- SmtpNtlmAuthenticationModule.cs
- WebMessageFormatHelper.cs
- PositiveTimeSpanValidatorAttribute.cs
- MimeTextImporter.cs
- Mappings.cs
- SyndicationDeserializer.cs
- HttpModuleCollection.cs
- OneOfConst.cs
- LocalizedNameDescriptionPair.cs
- EditorZoneBase.cs
- TaiwanCalendar.cs
- SqlHelper.cs
- ListDictionary.cs
- ErrorFormatter.cs
- DotNetATv1WindowsLogEntryDeserializer.cs
- DataSourceDescriptorCollection.cs
- RecordBuilder.cs
- OlePropertyStructs.cs
- UndirectedGraph.cs
- ToggleButton.cs
- FolderBrowserDialogDesigner.cs
- DefaultValueTypeConverter.cs
- BitStream.cs
- PersistenceTask.cs
- BrowserCapabilitiesCompiler.cs
- KeySpline.cs
- Highlights.cs
- FixedSOMImage.cs
- HitTestWithGeometryDrawingContextWalker.cs
- SqlInternalConnectionSmi.cs
- IndicFontClient.cs
- System.Data.OracleClient_BID.cs
- XmlSchemaParticle.cs
- RoleManagerSection.cs
- SpnegoTokenAuthenticator.cs
- EnumValAlphaComparer.cs
- XmlSchemaComplexContentExtension.cs
- XmlHierarchyData.cs
- Frame.cs
- StrongTypingException.cs
- Rethrow.cs
- OdbcReferenceCollection.cs
- WebException.cs
- ExpressionBindingsDialog.cs
- DoubleLinkListEnumerator.cs
- RunInstallerAttribute.cs
- HostedBindingBehavior.cs
- WebBrowserEvent.cs
- sqlinternaltransaction.cs
- DataGridrowEditEndingEventArgs.cs
- IChannel.cs
- SqlNotificationEventArgs.cs
- CodeDirectionExpression.cs
- SpeakCompletedEventArgs.cs
- ListItemsPage.cs
- Random.cs
- EditorAttribute.cs
- Style.cs
- Message.cs
- CoreSwitches.cs
- _HTTPDateParse.cs
- SQLConvert.cs
- DrawTreeNodeEventArgs.cs
- CallbackValidator.cs
- MergeLocalizationDirectives.cs
- FontSource.cs
- XmlDocumentSchema.cs
- EmptyQuery.cs
- SerialPort.cs
- PathStreamGeometryContext.cs
- ObjectMaterializedEventArgs.cs
- CodeSubDirectoriesCollection.cs
- RelatedImageListAttribute.cs
- TraceLog.cs
- XPathParser.cs
- SecureEnvironment.cs
- TransactionScope.cs
- ExpressionBuilder.cs
- DataGridCellsPanel.cs
- TextEditor.cs
- ToolStripButton.cs
- SqlGenerator.cs
- PropertyEmitter.cs
- DiffuseMaterial.cs
- RefreshEventArgs.cs
- Pointer.cs
- Resources.Designer.cs
- SecureStringHasher.cs
- AutomationPropertyInfo.cs
- CompositeCollectionView.cs
- SuspendDesigner.cs
- EntityContainerEmitter.cs
- MemoryMappedFileSecurity.cs
- SqlReferenceCollection.cs
- Soap.cs
- TimeoutException.cs
- COAUTHINFO.cs
- PeerNameRecord.cs