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
- SystemGatewayIPAddressInformation.cs
- Parallel.cs
- TablePatternIdentifiers.cs
- TrackBarRenderer.cs
- ObjectPersistData.cs
- WriteLine.cs
- WebPartChrome.cs
- PreloadedPackages.cs
- XmlSchemaCollection.cs
- UserMapPath.cs
- AdPostCacheSubstitution.cs
- NativeMethods.cs
- MdiWindowListItemConverter.cs
- ReadOnlyMetadataCollection.cs
- DesignTimeParseData.cs
- XmlSchemaAnyAttribute.cs
- OutputScopeManager.cs
- FixedTextBuilder.cs
- Path.cs
- DataControlButton.cs
- PcmConverter.cs
- AllMembershipCondition.cs
- SQLResource.cs
- Win32Exception.cs
- ProtocolImporter.cs
- RequestNavigateEventArgs.cs
- AssemblyBuilder.cs
- AttributedMetaModel.cs
- NonClientArea.cs
- GridViewHeaderRowPresenter.cs
- DataServiceProviderMethods.cs
- SqlConnectionHelper.cs
- InstanceNotReadyException.cs
- VirtualPathProvider.cs
- SafeViewOfFileHandle.cs
- IODescriptionAttribute.cs
- UndoManager.cs
- SystemColors.cs
- EntityClassGenerator.cs
- OracleConnectionFactory.cs
- HTMLTextWriter.cs
- StaticSiteMapProvider.cs
- CodeGeneratorAttribute.cs
- XPathScanner.cs
- PathSegmentCollection.cs
- TogglePatternIdentifiers.cs
- EntityCommandDefinition.cs
- HandleCollector.cs
- AssertSection.cs
- FormsAuthenticationCredentials.cs
- EntryWrittenEventArgs.cs
- Math.cs
- TypeDescriptorFilterService.cs
- ReadOnlyAttribute.cs
- PointConverter.cs
- ControlCollection.cs
- SqlProviderServices.cs
- XmlDownloadManager.cs
- ChannelPool.cs
- HtmlAnchor.cs
- PropertyGeneratedEventArgs.cs
- XXXInfos.cs
- SmiEventSink_Default.cs
- HMACSHA256.cs
- ToolStripRenderEventArgs.cs
- Matrix3D.cs
- SQLBinary.cs
- MutexSecurity.cs
- CodeTypeDelegate.cs
- ToolboxControl.cs
- x509utils.cs
- PublishLicense.cs
- InstanceCollisionException.cs
- UserControl.cs
- SqlRowUpdatingEvent.cs
- StreamWriter.cs
- PopupEventArgs.cs
- FixedFindEngine.cs
- ResourceExpressionEditor.cs
- DataGridItemAutomationPeer.cs
- ItemList.cs
- FlowDocumentView.cs
- TextParagraphView.cs
- OpacityConverter.cs
- ComponentRenameEvent.cs
- XmlBoundElement.cs
- TextProperties.cs
- TemplateEditingVerb.cs
- FixedNode.cs
- AddInServer.cs
- TranslateTransform.cs
- IntPtr.cs
- BaseInfoTable.cs
- DataControlField.cs
- ListSortDescription.cs
- XmlAtomicValue.cs
- ToolboxItemWrapper.cs
- Translator.cs
- UIAgentRequest.cs
- WebPartActionVerb.cs