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
- QueryCursorEventArgs.cs
- PreservationFileWriter.cs
- NetworkCredential.cs
- TreeIterator.cs
- DecoderExceptionFallback.cs
- AdRotatorDesigner.cs
- LambdaExpression.cs
- VisualBrush.cs
- FaultImportOptions.cs
- Mappings.cs
- ButtonPopupAdapter.cs
- PropertyChangedEventArgs.cs
- XmlNodeComparer.cs
- ContextQuery.cs
- DbDataAdapter.cs
- WebPartConnectionsDisconnectVerb.cs
- DataTableNameHandler.cs
- DuplicateWaitObjectException.cs
- MediaContextNotificationWindow.cs
- UrlMapping.cs
- FunctionQuery.cs
- StateMachineWorkflow.cs
- PipelineComponent.cs
- InvokeGenerator.cs
- CurrentChangingEventArgs.cs
- PrimitiveCodeDomSerializer.cs
- PathFigure.cs
- UserControlDocumentDesigner.cs
- Ops.cs
- EntityContainerEmitter.cs
- Soap12ProtocolImporter.cs
- SchemaObjectWriter.cs
- TransformProviderWrapper.cs
- CodeDomDesignerLoader.cs
- TablePatternIdentifiers.cs
- HwndSource.cs
- PageThemeCodeDomTreeGenerator.cs
- AuthenticationException.cs
- SecurityAttributeGenerationHelper.cs
- RegexCompiler.cs
- MD5CryptoServiceProvider.cs
- DataGridViewTextBoxColumn.cs
- WindowPattern.cs
- SplineKeyFrames.cs
- SafeCoTaskMem.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- Help.cs
- ReachSerializer.cs
- ChangeNode.cs
- AddressAlreadyInUseException.cs
- SafeProcessHandle.cs
- ImageInfo.cs
- XPathNodeInfoAtom.cs
- CellRelation.cs
- FaultBookmark.cs
- TypeForwardedFromAttribute.cs
- StringValidator.cs
- HttpFileCollection.cs
- SerTrace.cs
- PackagePart.cs
- DSACryptoServiceProvider.cs
- DesignerAdapterUtil.cs
- StylusOverProperty.cs
- TextEditorContextMenu.cs
- Shape.cs
- ColorBlend.cs
- ConcurrentBag.cs
- WebBrowser.cs
- DependencyProperty.cs
- SettingsAttributeDictionary.cs
- DataBindingHandlerAttribute.cs
- TypeUnloadedException.cs
- FixedFlowMap.cs
- WebPartTransformerCollection.cs
- DuplexChannel.cs
- Dictionary.cs
- Button.cs
- Size.cs
- OdbcConnectionHandle.cs
- TextRangeEdit.cs
- LineUtil.cs
- XmlWhitespace.cs
- EncoderParameter.cs
- TypeConverterHelper.cs
- SiteMapDataSourceDesigner.cs
- Cursors.cs
- CqlGenerator.cs
- BoundingRectTracker.cs
- PersistenceException.cs
- SuppressMergeCheckAttribute.cs
- ThreadInterruptedException.cs
- SqlSelectStatement.cs
- DbMetaDataColumnNames.cs
- Encoding.cs
- InkCanvasAutomationPeer.cs
- Exception.cs
- XmlAttributes.cs
- RuntimeHelpers.cs
- ToolStripSplitStackLayout.cs
- recordstatescratchpad.cs