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
- Journal.cs
- TdsParserSafeHandles.cs
- XamlBrushSerializer.cs
- LinkConverter.cs
- ImmutableClientRuntime.cs
- SymbolTable.cs
- QfeChecker.cs
- HTMLTagNameToTypeMapper.cs
- TextDocumentView.cs
- DetailsView.cs
- TypefaceMap.cs
- documentsequencetextpointer.cs
- Hex.cs
- AspCompat.cs
- OrderedDictionary.cs
- VirtualDirectoryMappingCollection.cs
- CompiledRegexRunnerFactory.cs
- CheckableControlBaseAdapter.cs
- OdbcError.cs
- ColumnCollection.cs
- DesignerForm.cs
- WebPartDisplayMode.cs
- DataGridViewLinkColumn.cs
- EntityKey.cs
- NumericUpDownAccelerationCollection.cs
- PermissionSet.cs
- Polygon.cs
- SeparatorAutomationPeer.cs
- XhtmlConformanceSection.cs
- ActivityCodeGenerator.cs
- HideDisabledControlAdapter.cs
- ProcessStartInfo.cs
- _LoggingObject.cs
- DataGridViewColumnEventArgs.cs
- PtsCache.cs
- PointUtil.cs
- ConfigXmlComment.cs
- ExpressionBindingCollection.cs
- GridViewItemAutomationPeer.cs
- ComponentSerializationService.cs
- KnownTypeHelper.cs
- XmlReflectionImporter.cs
- TreeViewBindingsEditorForm.cs
- InstanceOwnerQueryResult.cs
- SoapSchemaImporter.cs
- DataViewSettingCollection.cs
- ReferencedCollectionType.cs
- SlipBehavior.cs
- DataKey.cs
- ResourcesGenerator.cs
- WebPartEventArgs.cs
- BinaryReader.cs
- HtmlControl.cs
- TextEndOfSegment.cs
- WebPartMenu.cs
- SystemColors.cs
- ProcessInfo.cs
- IERequestCache.cs
- FormClosedEvent.cs
- TrustLevelCollection.cs
- EasingFunctionBase.cs
- UserNameSecurityTokenProvider.cs
- ProcessModule.cs
- HtmlTableRowCollection.cs
- ReadOnlyDictionary.cs
- ManipulationStartingEventArgs.cs
- ToolStrip.cs
- XmlnsCompatibleWithAttribute.cs
- GeometryDrawing.cs
- WebControl.cs
- PackageProperties.cs
- BulletChrome.cs
- SecurityContext.cs
- PolyLineSegment.cs
- TextDocumentView.cs
- SlipBehavior.cs
- wmiprovider.cs
- TableItemPatternIdentifiers.cs
- GridViewItemAutomationPeer.cs
- UnsupportedPolicyOptionsException.cs
- VisualStyleInformation.cs
- SqlDataSource.cs
- WindowsPrincipal.cs
- ComplexType.cs
- AsnEncodedData.cs
- Cursors.cs
- IgnorePropertiesAttribute.cs
- NotificationContext.cs
- HtmlTernaryTree.cs
- WebException.cs
- TypeBuilder.cs
- XmlNode.cs
- TemplateBuilder.cs
- PropertyDescriptorComparer.cs
- DataObject.cs
- StringUtil.cs
- SHA512CryptoServiceProvider.cs
- TextRangeEdit.cs
- ToolStripPanelDesigner.cs
- MemberRelationshipService.cs