Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / ServiceModelDictionary.cs / 1 / ServiceModelDictionary.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel { using System.Xml; using System.Collections.Generic; class ServiceModelDictionary : IXmlDictionary { static public readonly ServiceModelDictionary Version1 = new ServiceModelDictionary(new ServiceModelStringsVersion1()); ServiceModelStrings strings; int count; XmlDictionaryString[] dictionaryStrings1; XmlDictionaryString[] dictionaryStrings2; Dictionarydictionary; XmlDictionaryString[] versionedDictionaryStrings; public ServiceModelDictionary(ServiceModelStrings strings) { this.strings = strings; this.count = strings.Count; } static public ServiceModelDictionary CurrentVersion { get { return Version1; } } public XmlDictionaryString CreateString(string value, int key) { return new XmlDictionaryString(this, value, key); } public bool TryLookup(string key, out XmlDictionaryString value) { if (key == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("key")); if (this.dictionary == null) { Dictionary dictionary = new Dictionary (count); for (int i = 0; i < count; i++) dictionary.Add(strings[i], i); this.dictionary = dictionary; } int id; if (this.dictionary.TryGetValue(key, out id)) return TryLookup(id, out value); value = null; return false; } public bool TryLookup(int key, out XmlDictionaryString value) { const int keyThreshold = 32; if (key < 0 || key >= count) { value = null; return false; } XmlDictionaryString s; if (key < keyThreshold) { if (dictionaryStrings1 == null) dictionaryStrings1 = new XmlDictionaryString[keyThreshold]; s = dictionaryStrings1[key]; if (s == null) { s = CreateString(strings[key], key); dictionaryStrings1[key] = s; } } else { if (dictionaryStrings2 == null) dictionaryStrings2 = new XmlDictionaryString[count - keyThreshold]; s = dictionaryStrings2[key - keyThreshold]; if (s == null) { s = CreateString(strings[key], key); dictionaryStrings2[key - keyThreshold] = s; } } value = s; return true; } public bool TryLookup(XmlDictionaryString key, out XmlDictionaryString value) { if (key == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("key")); if (key.Dictionary == this) { value = key; return true; } if (key.Dictionary == CurrentVersion) { if (versionedDictionaryStrings == null) versionedDictionaryStrings = new XmlDictionaryString[CurrentVersion.count]; XmlDictionaryString s = versionedDictionaryStrings[key.Key]; if (s == null) { if (!TryLookup(key.Value, out s)) { value = null; return false; } versionedDictionaryStrings[key.Key] = s; } value = s; return true; } value = 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
- TextFormatter.cs
- AdditionalEntityFunctions.cs
- LinkedList.cs
- MruCache.cs
- LinkArea.cs
- EntityKeyElement.cs
- Token.cs
- ResourceIDHelper.cs
- BadImageFormatException.cs
- EdmPropertyAttribute.cs
- OrderByExpression.cs
- ServiceBuildProvider.cs
- StringComparer.cs
- HotSpot.cs
- TypeDescriptionProviderAttribute.cs
- WebScriptEndpoint.cs
- KnownBoxes.cs
- DropDownButton.cs
- QilName.cs
- _LocalDataStoreMgr.cs
- ConnectionStringSettingsCollection.cs
- Events.cs
- QueryExpr.cs
- InputScope.cs
- DesignerEditorPartChrome.cs
- Bezier.cs
- SystemWebSectionGroup.cs
- ClientOptions.cs
- ContentType.cs
- TrackBarRenderer.cs
- MetadataFile.cs
- XmlDeclaration.cs
- PenLineJoinValidation.cs
- LassoSelectionBehavior.cs
- RuntimeHelpers.cs
- SecurityResources.cs
- Duration.cs
- ZipIOCentralDirectoryFileHeader.cs
- ResourceProperty.cs
- SourceChangedEventArgs.cs
- SQLGuid.cs
- ComponentResourceManager.cs
- ToolStripLabel.cs
- OperationInvokerTrace.cs
- OdbcException.cs
- TextInfo.cs
- Function.cs
- CompositeTypefaceMetrics.cs
- DataTemplate.cs
- TopClause.cs
- Rijndael.cs
- SmtpCommands.cs
- ImageBrush.cs
- ISAPIApplicationHost.cs
- ReaderWriterLock.cs
- IgnorePropertiesAttribute.cs
- TraceUtility.cs
- OleServicesContext.cs
- ValidationHelpers.cs
- FragmentQueryProcessor.cs
- TextEffect.cs
- LockCookie.cs
- OleDbErrorCollection.cs
- VisualBasicImportReference.cs
- DataControlField.cs
- WebPartsSection.cs
- TrustManagerMoreInformation.cs
- AttachedAnnotationChangedEventArgs.cs
- NullableConverter.cs
- SchemaSetCompiler.cs
- ContentIterators.cs
- ViewKeyConstraint.cs
- PageHandlerFactory.cs
- HierarchicalDataBoundControl.cs
- XsltSettings.cs
- SamlAssertionKeyIdentifierClause.cs
- SizeFConverter.cs
- _LocalDataStore.cs
- PersistenceTypeAttribute.cs
- XmlNamespaceMapping.cs
- Function.cs
- SQLMoneyStorage.cs
- ServiceInfoCollection.cs
- TextSelectionProcessor.cs
- UriParserTemplates.cs
- ErasingStroke.cs
- AggregateNode.cs
- Lock.cs
- DateTimeValueSerializerContext.cs
- PackageRelationshipCollection.cs
- MouseButton.cs
- ScrollableControl.cs
- EventArgs.cs
- xsdvalidator.cs
- SamlSecurityTokenAuthenticator.cs
- PreservationFileReader.cs
- HTMLTagNameToTypeMapper.cs
- MDIWindowDialog.cs
- ComponentChangingEvent.cs
- SpeakInfo.cs