Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / clr / src / BCL / System / Runtime / Serialization / SerializationObjectManager.cs / 1 / SerializationObjectManager.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SerializationObjectManager ** ** ** Purpose: Encapsulates serialization time management, mainly invoking serialization events ** ** ============================================================*/ namespace System.Runtime.Serialization { using System; using System.Collections; using System.Runtime.Serialization; using System.Security.Permissions; public sealed class SerializationObjectManager{ private Hashtable m_objectSeenTable = new Hashtable(); // Table to keep track of objects [OnSerializing] has been called on private SerializationEventHandler m_onSerializedHandler; private StreamingContext m_context; public SerializationObjectManager(StreamingContext context) { m_context = context; m_objectSeenTable = new Hashtable(); } [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] public void RegisterObject(Object obj) { // Invoke OnSerializing for this object SerializationEvents cache = SerializationEventsCache.GetSerializationEventsForType(obj.GetType()); // Check to make sure type has serializing events if (cache.HasOnSerializingEvents) { // Check to see if we have invoked the events on the object if (m_objectSeenTable[obj] == null) { m_objectSeenTable[obj] = true; // Invoke the events cache.InvokeOnSerializing(obj, m_context); // Register for OnSerialized event AddOnSerialized(obj); } } } public void RaiseOnSerializedEvent() { if (m_onSerializedHandler != null) { m_onSerializedHandler(m_context); } } private void AddOnSerialized(Object obj) { SerializationEvents cache = SerializationEventsCache.GetSerializationEventsForType(obj.GetType()); m_onSerializedHandler = cache.AddOnSerialized(obj, m_onSerializedHandler); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SerializationObjectManager ** ** ** Purpose: Encapsulates serialization time management, mainly invoking serialization events ** ** ============================================================*/ namespace System.Runtime.Serialization { using System; using System.Collections; using System.Runtime.Serialization; using System.Security.Permissions; public sealed class SerializationObjectManager{ private Hashtable m_objectSeenTable = new Hashtable(); // Table to keep track of objects [OnSerializing] has been called on private SerializationEventHandler m_onSerializedHandler; private StreamingContext m_context; public SerializationObjectManager(StreamingContext context) { m_context = context; m_objectSeenTable = new Hashtable(); } [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] public void RegisterObject(Object obj) { // Invoke OnSerializing for this object SerializationEvents cache = SerializationEventsCache.GetSerializationEventsForType(obj.GetType()); // Check to make sure type has serializing events if (cache.HasOnSerializingEvents) { // Check to see if we have invoked the events on the object if (m_objectSeenTable[obj] == null) { m_objectSeenTable[obj] = true; // Invoke the events cache.InvokeOnSerializing(obj, m_context); // Register for OnSerialized event AddOnSerialized(obj); } } } public void RaiseOnSerializedEvent() { if (m_onSerializedHandler != null) { m_onSerializedHandler(m_context); } } private void AddOnSerialized(Object obj) { SerializationEvents cache = SerializationEventsCache.GetSerializationEventsForType(obj.GetType()); m_onSerializedHandler = cache.AddOnSerialized(obj, m_onSerializedHandler); } } } // 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
- AnnotationResourceChangedEventArgs.cs
- IdnMapping.cs
- UIElementParagraph.cs
- EmptyCollection.cs
- PersonalizationStateInfoCollection.cs
- DecimalAnimation.cs
- storagemappingitemcollection.viewdictionary.cs
- PropertyChangingEventArgs.cs
- SqlConnection.cs
- PassportPrincipal.cs
- SortDescriptionCollection.cs
- DataGridColumnHeaderAutomationPeer.cs
- XPathQueryGenerator.cs
- ArrayElementGridEntry.cs
- oledbmetadatacolumnnames.cs
- DBSchemaRow.cs
- ServerReliableChannelBinder.cs
- Validator.cs
- entityreference_tresulttype.cs
- HtmlFormWrapper.cs
- SessionEndingCancelEventArgs.cs
- LabelExpression.cs
- CodeExporter.cs
- PageClientProxyGenerator.cs
- MultipleViewProviderWrapper.cs
- Pen.cs
- EntityDataSourceStatementEditor.cs
- ToolStripSplitStackLayout.cs
- HotSpotCollection.cs
- Control.cs
- Color.cs
- documentsequencetextcontainer.cs
- AutomationProperties.cs
- ReferenceSchema.cs
- HttpCacheVary.cs
- ObjRef.cs
- DrawingAttributesDefaultValueFactory.cs
- AssemblyCache.cs
- SessionStateUtil.cs
- LogManagementAsyncResult.cs
- Cloud.cs
- XmlWrappingReader.cs
- ExtendedPropertyInfo.cs
- RowToParametersTransformer.cs
- ReflectTypeDescriptionProvider.cs
- namescope.cs
- IncrementalHitTester.cs
- Int32Rect.cs
- HttpConfigurationSystem.cs
- SolidColorBrush.cs
- RoutedPropertyChangedEventArgs.cs
- SystemPens.cs
- SoapEnvelopeProcessingElement.cs
- PartialClassGenerationTask.cs
- SoapCommonClasses.cs
- X509Certificate2Collection.cs
- UpdatableGenericsFeature.cs
- CodeDomSerializerBase.cs
- DurationConverter.cs
- FontSourceCollection.cs
- UrlUtility.cs
- BufferModesCollection.cs
- ServiceContractListItem.cs
- BulletedListDesigner.cs
- CodePageUtils.cs
- SqlCacheDependencyDatabase.cs
- WindowsPen.cs
- InternalException.cs
- ErrorFormatter.cs
- ChannelCacheSettings.cs
- HttpWriter.cs
- Thumb.cs
- SecurityManager.cs
- RecognizerBase.cs
- SparseMemoryStream.cs
- XmlNodeChangedEventArgs.cs
- DynamicILGenerator.cs
- EnumBuilder.cs
- ItemAutomationPeer.cs
- SystemIcmpV4Statistics.cs
- EditorPartCollection.cs
- MasterPage.cs
- TextBoxDesigner.cs
- DataSourceCacheDurationConverter.cs
- FilteredXmlReader.cs
- DateTimeUtil.cs
- VBCodeProvider.cs
- RuntimeConfig.cs
- ListDictionaryInternal.cs
- AstNode.cs
- StylusEventArgs.cs
- RIPEMD160Managed.cs
- PerformanceCounter.cs
- Win32.cs
- PageParserFilter.cs
- FunctionQuery.cs
- HttpModuleAction.cs
- CssClassPropertyAttribute.cs
- WebPartMovingEventArgs.cs
- compensatingcollection.cs