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
- FaultFormatter.cs
- LineServicesCallbacks.cs
- MessageBuilder.cs
- DoubleCollectionValueSerializer.cs
- fixedPageContentExtractor.cs
- DelegateSerializationHolder.cs
- NotifyIcon.cs
- RecordsAffectedEventArgs.cs
- DataGridGeneralPage.cs
- ADMembershipUser.cs
- ExpressionBuilderCollection.cs
- OutputCacheSettings.cs
- UrlMapping.cs
- DateTimeFormat.cs
- IERequestCache.cs
- SqlFileStream.cs
- XmlNamespaceMappingCollection.cs
- InputBindingCollection.cs
- LogicalExpressionTypeConverter.cs
- FileInfo.cs
- CustomAttribute.cs
- ZoneLinkButton.cs
- EntityTemplateUserControl.cs
- SessionState.cs
- ObjectItemCachedAssemblyLoader.cs
- CompilationSection.cs
- ConvertEvent.cs
- SmiMetaDataProperty.cs
- PropVariant.cs
- TypeSource.cs
- AxHost.cs
- PeerObject.cs
- RepeatBehavior.cs
- EmptyEnumerable.cs
- RoleGroup.cs
- GenericFlowSwitchHelper.cs
- RowVisual.cs
- ItemsChangedEventArgs.cs
- PolyBezierSegment.cs
- TextEffect.cs
- FieldNameLookup.cs
- FilterQuery.cs
- ThreadStaticAttribute.cs
- ResolvedKeyFrameEntry.cs
- RandomNumberGenerator.cs
- MetaData.cs
- XPathSingletonIterator.cs
- AndCondition.cs
- RadioButtonBaseAdapter.cs
- XmlSchemaInclude.cs
- Stream.cs
- CursorConverter.cs
- MetaTable.cs
- PasswordDeriveBytes.cs
- TemplateBindingExtension.cs
- QueryValue.cs
- SecurityUtils.cs
- AspProxy.cs
- InteropAutomationProvider.cs
- XmlSchemaGroup.cs
- ButtonBase.cs
- PolyQuadraticBezierSegment.cs
- PropertyInfo.cs
- GlobalEventManager.cs
- CaseInsensitiveHashCodeProvider.cs
- PreProcessor.cs
- SqlDataReader.cs
- AsyncCompletedEventArgs.cs
- BinaryConverter.cs
- ConfigXmlElement.cs
- DateTimeOffsetAdapter.cs
- Fx.cs
- Activator.cs
- EncodingInfo.cs
- ElementFactory.cs
- DataTableCollection.cs
- HttpConfigurationSystem.cs
- SafeHandle.cs
- RegionIterator.cs
- WSSecurityOneDotZeroReceiveSecurityHeader.cs
- WebHttpSecurity.cs
- FatalException.cs
- TextTrailingWordEllipsis.cs
- XmlDeclaration.cs
- Registry.cs
- UIElement.cs
- Verify.cs
- ScriptManager.cs
- NetworkInformationException.cs
- DataGridViewBindingCompleteEventArgs.cs
- AccessText.cs
- VirtualizedContainerService.cs
- SmtpClient.cs
- TextSimpleMarkerProperties.cs
- CombinedGeometry.cs
- ValidationSummary.cs
- WindowsEditBoxRange.cs
- HttpSessionStateBase.cs
- odbcmetadatafactory.cs
- XmlNamespaceManager.cs