Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- XmlNotation.cs
- NetworkAddressChange.cs
- FixedTextPointer.cs
- ListViewCommandEventArgs.cs
- FrugalList.cs
- TableStyle.cs
- UIElement.cs
- ClosableStream.cs
- X509Certificate2.cs
- DataGridViewCellCollection.cs
- OdbcDataReader.cs
- MissingMethodException.cs
- SettingsProperty.cs
- ProfileParameter.cs
- FigureHelper.cs
- FileSystemInfo.cs
- WindowsTitleBar.cs
- ControlValuePropertyAttribute.cs
- ToolboxComponentsCreatedEventArgs.cs
- Html32TextWriter.cs
- BufferAllocator.cs
- CollectionChangeEventArgs.cs
- compensatingcollection.cs
- CachedPathData.cs
- TableLayoutSettingsTypeConverter.cs
- TraceSection.cs
- SimplePropertyEntry.cs
- ZoneMembershipCondition.cs
- DecimalAnimationBase.cs
- HttpModule.cs
- AdornerHitTestResult.cs
- ZoneMembershipCondition.cs
- TransformCollection.cs
- HtmlTableCell.cs
- GPRECTF.cs
- HandleCollector.cs
- DesignerActionItem.cs
- ListView.cs
- PageOutputQuality.cs
- UserUseLicenseDictionaryLoader.cs
- ViewCellSlot.cs
- ExtendedPropertyCollection.cs
- IgnoreSection.cs
- FrameSecurityDescriptor.cs
- PeerNameRegistration.cs
- MetabaseServerConfig.cs
- StringSource.cs
- InlineCollection.cs
- SoapIgnoreAttribute.cs
- AnonymousIdentificationSection.cs
- FontStretches.cs
- GeometryConverter.cs
- ObjectDataSourceStatusEventArgs.cs
- PeerDuplexChannel.cs
- ClientConfigPaths.cs
- ViewValidator.cs
- RangeValuePatternIdentifiers.cs
- DefaultWorkflowTransactionService.cs
- ConnectionManagementElementCollection.cs
- XmlSchemaInferenceException.cs
- StagingAreaInputItem.cs
- IIS7WorkerRequest.cs
- ObjectSecurity.cs
- SafeNativeMethods.cs
- HtmlLiteralTextAdapter.cs
- Currency.cs
- EdmPropertyAttribute.cs
- Base64Encoder.cs
- pingexception.cs
- DataColumnPropertyDescriptor.cs
- AutomationElement.cs
- CqlParser.cs
- DataSourceUtil.cs
- TableLayoutRowStyleCollection.cs
- ProtocolsSection.cs
- ClientBuildManagerCallback.cs
- ReadWriteObjectLock.cs
- NotSupportedException.cs
- DataSvcMapFileSerializer.cs
- PagerSettings.cs
- InputProcessorProfilesLoader.cs
- OracleConnectionString.cs
- FastEncoder.cs
- Transform.cs
- ExternalFile.cs
- CodeIdentifiers.cs
- ResourceSet.cs
- ZipIOModeEnforcingStream.cs
- XmlQueryType.cs
- ContextMenuStrip.cs
- TTSEngineTypes.cs
- CleanUpVirtualizedItemEventArgs.cs
- TypeExtensions.cs
- LinqDataSourceUpdateEventArgs.cs
- ToolZone.cs
- CTreeGenerator.cs
- IndicFontClient.cs
- WebPartEventArgs.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- HttpContext.cs