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
- UnknownWrapper.cs
- TabletCollection.cs
- PolicyLevel.cs
- Privilege.cs
- TextEditorLists.cs
- BufferedResponseStream.cs
- BaseAsyncResult.cs
- SqlExpressionNullability.cs
- dataprotectionpermissionattribute.cs
- SolidBrush.cs
- SqlAliaser.cs
- LowerCaseStringConverter.cs
- HttpHandlersSection.cs
- DataControlImageButton.cs
- MatrixCamera.cs
- TrackingStringDictionary.cs
- GridViewCancelEditEventArgs.cs
- HitTestWithGeometryDrawingContextWalker.cs
- RijndaelCryptoServiceProvider.cs
- counter.cs
- WebPartDisplayModeCollection.cs
- ExceptionValidationRule.cs
- ClientRuntime.cs
- sqlstateclientmanager.cs
- securestring.cs
- ProcessRequestAsyncResult.cs
- TypedAsyncResult.cs
- HandoffBehavior.cs
- AttachedAnnotation.cs
- SharedConnectionWorkflowTransactionService.cs
- CodePropertyReferenceExpression.cs
- ProfileServiceManager.cs
- EmissiveMaterial.cs
- _ConnectStream.cs
- StreamResourceInfo.cs
- ServicePerformanceCounters.cs
- XPathQilFactory.cs
- XmlTextWriter.cs
- CompressEmulationStream.cs
- VectorCollection.cs
- ListViewUpdateEventArgs.cs
- SchemaNames.cs
- MinimizableAttributeTypeConverter.cs
- DataSourceCache.cs
- EnumerableRowCollection.cs
- Menu.cs
- WpfXamlLoader.cs
- TabletDevice.cs
- JavaScriptSerializer.cs
- DataGridColumn.cs
- RoutedEvent.cs
- Int16AnimationUsingKeyFrames.cs
- PassportAuthenticationEventArgs.cs
- SoapAttributeOverrides.cs
- EventHandlers.cs
- BitmapEffectDrawing.cs
- VirtualDirectoryMappingCollection.cs
- WebContext.cs
- CatalogZoneBase.cs
- InternalSafeNativeMethods.cs
- SqlInternalConnectionTds.cs
- followingsibling.cs
- SerializationHelper.cs
- SharedTcpTransportManager.cs
- StaticTextPointer.cs
- Translator.cs
- HttpCookiesSection.cs
- DebuggerService.cs
- ForeignKeyConstraint.cs
- TargetConverter.cs
- MissingFieldException.cs
- ConstraintEnumerator.cs
- TimerElapsedEvenArgs.cs
- ValidatorCollection.cs
- HasCopySemanticsAttribute.cs
- HtmlGenericControl.cs
- EditorResources.cs
- MissingSatelliteAssemblyException.cs
- LockCookie.cs
- WebPartTransformerCollection.cs
- Listbox.cs
- AssemblyCollection.cs
- PeerFlooder.cs
- SurrogateSelector.cs
- ResourceBinder.cs
- MenuAutomationPeer.cs
- RoutedCommand.cs
- HwndSource.cs
- DetailsViewRow.cs
- ConfigXmlWhitespace.cs
- RIPEMD160Managed.cs
- DrawingVisualDrawingContext.cs
- XmlSerializerFactory.cs
- DataGridViewColumnConverter.cs
- DelegateArgumentValue.cs
- MeshGeometry3D.cs
- ChangesetResponse.cs
- XmlSequenceWriter.cs
- MetaChildrenColumn.cs
- WebCategoryAttribute.cs