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
- CoreSwitches.cs
- DataPagerFieldItem.cs
- X509SubjectKeyIdentifierClause.cs
- TextElementEnumerator.cs
- GeneralTransformGroup.cs
- TextModifier.cs
- ZipIOExtraFieldZip64Element.cs
- ClientConfigurationSystem.cs
- Assert.cs
- LineVisual.cs
- DataControlCommands.cs
- ThreadInterruptedException.cs
- DataGridViewLinkColumn.cs
- BufferedOutputStream.cs
- ShaderEffect.cs
- GlyphRunDrawing.cs
- ProxyWebPart.cs
- LiteralSubsegment.cs
- StringKeyFrameCollection.cs
- HttpClientCertificate.cs
- ManagedFilter.cs
- Underline.cs
- StylusCaptureWithinProperty.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- TableHeaderCell.cs
- RenderCapability.cs
- PageParserFilter.cs
- RadioButton.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- SettingsPropertyValueCollection.cs
- TemplateField.cs
- ToolStripOverflow.cs
- XmlSchemaSimpleTypeRestriction.cs
- SubpageParaClient.cs
- ObjectCloneHelper.cs
- XDRSchema.cs
- ResourceFallbackManager.cs
- RSAProtectedConfigurationProvider.cs
- PrintDocument.cs
- SByteStorage.cs
- DataGridViewColumnEventArgs.cs
- InputScope.cs
- StackBuilderSink.cs
- PermissionListSet.cs
- PowerEase.cs
- RadioButtonList.cs
- LayoutSettings.cs
- _ProxyRegBlob.cs
- CompiledQueryCacheKey.cs
- EventArgs.cs
- FontFamilyValueSerializer.cs
- RequestQueryParser.cs
- RequestCachingSection.cs
- GZipDecoder.cs
- ZipPackage.cs
- GetPageCompletedEventArgs.cs
- ImageEditor.cs
- NamedPipeProcessProtocolHandler.cs
- ThreadPoolTaskScheduler.cs
- Popup.cs
- cookiecontainer.cs
- Visitor.cs
- SubMenuStyle.cs
- StringValidatorAttribute.cs
- ConfigurationSchemaErrors.cs
- ObjectStateEntryDbDataRecord.cs
- CompositeCollectionView.cs
- Journal.cs
- XmlNodeChangedEventArgs.cs
- ConnectorRouter.cs
- AsyncDataRequest.cs
- XmlDictionaryWriter.cs
- HttpBrowserCapabilitiesWrapper.cs
- XMLSchema.cs
- LinqDataSourceEditData.cs
- FixedTextContainer.cs
- ConfigurationStrings.cs
- ToolStripTemplateNode.cs
- SerialPort.cs
- arc.cs
- BitArray.cs
- KeyGestureConverter.cs
- XmlKeywords.cs
- InstanceKeyView.cs
- DataSvcMapFileSerializer.cs
- BitmapScalingModeValidation.cs
- CursorConverter.cs
- StaticDataManager.cs
- PerformanceCounters.cs
- DbConnectionStringCommon.cs
- Light.cs
- VisualBasicSettings.cs
- SqlNode.cs
- PaintValueEventArgs.cs
- MulticastIPAddressInformationCollection.cs
- ObjectAssociationEndMapping.cs
- ValueProviderWrapper.cs
- AbstractExpressions.cs
- Debugger.cs
- TextHidden.cs