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
- BamlBinaryReader.cs
- XmlSchemaParticle.cs
- ImageMapEventArgs.cs
- SafeBitVector32.cs
- EditingMode.cs
- GenericParameterDataContract.cs
- SqlProcedureAttribute.cs
- TrackingProfileSerializer.cs
- XmlnsCache.cs
- FocusChangedEventArgs.cs
- TextEditorCharacters.cs
- NamespaceInfo.cs
- MarkupProperty.cs
- ClientOptions.cs
- SymbolType.cs
- RelatedImageListAttribute.cs
- PagesChangedEventArgs.cs
- DataChangedEventManager.cs
- SqlNotificationEventArgs.cs
- DataPagerFieldCollection.cs
- ContainerSelectorActiveEvent.cs
- ContainerControl.cs
- MetafileEditor.cs
- LoginAutoFormat.cs
- ColorComboBox.cs
- DeviceContext2.cs
- TableLayoutStyleCollection.cs
- LocalizabilityAttribute.cs
- RootDesignerSerializerAttribute.cs
- UICuesEvent.cs
- DataRow.cs
- WebPartVerbCollection.cs
- StructuralComparisons.cs
- StructureChangedEventArgs.cs
- ValidationHelper.cs
- XPathMultyIterator.cs
- DocumentOrderQuery.cs
- GridViewCancelEditEventArgs.cs
- MarginCollapsingState.cs
- TimeStampChecker.cs
- MultiBinding.cs
- MachineKey.cs
- BooleanStorage.cs
- Restrictions.cs
- MDIWindowDialog.cs
- ImplicitInputBrush.cs
- DataGridViewRowPostPaintEventArgs.cs
- xmlformatgeneratorstatics.cs
- FrameSecurityDescriptor.cs
- UserPersonalizationStateInfo.cs
- DoubleStorage.cs
- DbMetaDataColumnNames.cs
- DllNotFoundException.cs
- PageAsyncTaskManager.cs
- ConvertEvent.cs
- IdleTimeoutMonitor.cs
- WebDisplayNameAttribute.cs
- VBIdentifierName.cs
- UrlPropertyAttribute.cs
- TraceUtils.cs
- PathData.cs
- VariantWrapper.cs
- AnimatedTypeHelpers.cs
- Region.cs
- DataControlFieldCollection.cs
- ParallelActivityDesigner.cs
- WebPartMinimizeVerb.cs
- URIFormatException.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- ShowExpandedMultiValueConverter.cs
- AutoGeneratedField.cs
- IndependentlyAnimatedPropertyMetadata.cs
- DataControlField.cs
- ClientType.cs
- CodeFieldReferenceExpression.cs
- PersonalizationProviderHelper.cs
- WebPartZone.cs
- Vector3D.cs
- LinearGradientBrush.cs
- MetadataWorkspace.cs
- PageSettings.cs
- DockPatternIdentifiers.cs
- Win32MouseDevice.cs
- ClientConfigurationSystem.cs
- ButtonFlatAdapter.cs
- XmlSchemas.cs
- FixedPageAutomationPeer.cs
- HtmlTextArea.cs
- BufferBuilder.cs
- NeutralResourcesLanguageAttribute.cs
- ClientTarget.cs
- CorrelationManager.cs
- GraphicsContainer.cs
- GenericNameHandler.cs
- MergablePropertyAttribute.cs
- IndentTextWriter.cs
- SafeSecurityHelper.cs
- ContextProperty.cs
- UriExt.cs
- ErrorInfoXmlDocument.cs