Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / HybridObjectCache.cs / 1305376 / HybridObjectCache.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Runtime.Serialization { using System; using System.Xml; using System.Collections.Generic; internal class HybridObjectCache { DictionaryobjectDictionary; Dictionary referencedObjectDictionary; internal HybridObjectCache() { } internal void Add(string id, object obj) { if (objectDictionary == null) objectDictionary = new Dictionary (); object existingObject; if (objectDictionary.TryGetValue(id, out existingObject)) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.MultipleIdDefinition, id))); objectDictionary.Add(id, obj); } internal void Remove(string id) { if (objectDictionary != null) objectDictionary.Remove(id); } internal object GetObject(string id) { if (referencedObjectDictionary == null) { referencedObjectDictionary = new Dictionary (); referencedObjectDictionary.Add(id, null); } else if (!referencedObjectDictionary.ContainsKey(id)) { referencedObjectDictionary.Add(id, null); } if (objectDictionary != null) { object obj; objectDictionary.TryGetValue(id, out obj); return obj; } return null; } internal bool IsObjectReferenced(string id) { if (referencedObjectDictionary != null) { return referencedObjectDictionary.ContainsKey(id); } return false; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Runtime.Serialization { using System; using System.Xml; using System.Collections.Generic; internal class HybridObjectCache { Dictionary objectDictionary; Dictionary referencedObjectDictionary; internal HybridObjectCache() { } internal void Add(string id, object obj) { if (objectDictionary == null) objectDictionary = new Dictionary (); object existingObject; if (objectDictionary.TryGetValue(id, out existingObject)) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.MultipleIdDefinition, id))); objectDictionary.Add(id, obj); } internal void Remove(string id) { if (objectDictionary != null) objectDictionary.Remove(id); } internal object GetObject(string id) { if (referencedObjectDictionary == null) { referencedObjectDictionary = new Dictionary (); referencedObjectDictionary.Add(id, null); } else if (!referencedObjectDictionary.ContainsKey(id)) { referencedObjectDictionary.Add(id, null); } if (objectDictionary != null) { object obj; objectDictionary.TryGetValue(id, out obj); return obj; } return null; } internal bool IsObjectReferenced(string id) { if (referencedObjectDictionary != null) { return referencedObjectDictionary.ContainsKey(id); } 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
- SchemaInfo.cs
- XmlDocumentType.cs
- NativeCppClassAttribute.cs
- DataTableExtensions.cs
- RadioButton.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- HtmlFormAdapter.cs
- TemplateControlParser.cs
- SmtpSection.cs
- Win32SafeHandles.cs
- CompilerParameters.cs
- Transform3DGroup.cs
- _RequestCacheProtocol.cs
- X509CertificateStore.cs
- BooleanSwitch.cs
- Stroke2.cs
- SvcMapFileSerializer.cs
- Font.cs
- ContentType.cs
- WorkflowPageSetupDialog.cs
- TableRowGroup.cs
- GenericEnumerator.cs
- ContextProperty.cs
- ActivityValidator.cs
- ReadOnlyDictionary.cs
- TypeInfo.cs
- SqlTriggerContext.cs
- StyleXamlParser.cs
- NumericPagerField.cs
- PrinterSettings.cs
- SecurityTokenSerializer.cs
- SEHException.cs
- Compiler.cs
- ExpandCollapseProviderWrapper.cs
- GetPageNumberCompletedEventArgs.cs
- RegexGroup.cs
- ExpressionBinding.cs
- FactoryId.cs
- EventKeyword.cs
- BamlTreeUpdater.cs
- WindowInteractionStateTracker.cs
- GlobalEventManager.cs
- SynchronizedCollection.cs
- CommandPlan.cs
- XmlStringTable.cs
- XmlSchemaExternal.cs
- SharedHttpsTransportManager.cs
- WebScriptMetadataMessageEncoderFactory.cs
- SizeValueSerializer.cs
- OdbcConnection.cs
- ToolStripItemDesigner.cs
- XmlKeywords.cs
- CancellationState.cs
- CellTreeNode.cs
- UserControl.cs
- WhitespaceRule.cs
- newitemfactory.cs
- Control.cs
- WindowsListViewItem.cs
- _ContextAwareResult.cs
- TransactionTable.cs
- _emptywebproxy.cs
- PropertyGridCommands.cs
- InheritanceContextChangedEventManager.cs
- BoundingRectTracker.cs
- DateTimeStorage.cs
- AndCondition.cs
- AlternateView.cs
- PersonalizationProviderHelper.cs
- OracleCommandSet.cs
- Range.cs
- BStrWrapper.cs
- WindowClosedEventArgs.cs
- DurationConverter.cs
- AsymmetricKeyExchangeDeformatter.cs
- MSAANativeProvider.cs
- InputManager.cs
- TextEndOfSegment.cs
- MenuCommand.cs
- TextProperties.cs
- SmiGettersStream.cs
- SignerInfo.cs
- FieldToken.cs
- HyperLink.cs
- XmlSchemaChoice.cs
- DocumentApplicationJournalEntry.cs
- WebPartMovingEventArgs.cs
- VerificationAttribute.cs
- NaturalLanguageHyphenator.cs
- Win32Native.cs
- CharacterShapingProperties.cs
- ServiceDebugElement.cs
- WebPartDisplayMode.cs
- TableParagraph.cs
- Utils.cs
- DataTableNewRowEvent.cs
- GridLength.cs
- CompilerScopeManager.cs
- AdRotatorDesigner.cs
- BinaryConverter.cs