Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Runtime / Serialization / SerializationObjectManager.cs / 1305376 / 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(); } [System.Security.SecurityCritical] // auto-generated_required 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(); } [System.Security.SecurityCritical] // auto-generated_required 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
- TemplateKeyConverter.cs
- WinOEToolBoxItem.cs
- GestureRecognizer.cs
- SecUtil.cs
- loginstatus.cs
- TrackingMemoryStream.cs
- XmlReaderSettings.cs
- MsmqIntegrationInputChannel.cs
- ListItemCollection.cs
- FixedSOMLineRanges.cs
- _SslStream.cs
- HttpCapabilitiesBase.cs
- CompilerResults.cs
- ImageDesigner.cs
- SemanticResolver.cs
- CommandArguments.cs
- LayoutUtils.cs
- ThemeableAttribute.cs
- XmlEncodedRawTextWriter.cs
- OpenTypeCommon.cs
- ListViewItemSelectionChangedEvent.cs
- ResourceExpressionBuilder.cs
- GenerateHelper.cs
- DeleteHelper.cs
- PointKeyFrameCollection.cs
- PtsHelper.cs
- StronglyTypedResourceBuilder.cs
- BinaryConverter.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- ContourSegment.cs
- BindingNavigator.cs
- DataGridRowHeader.cs
- ConnectionConsumerAttribute.cs
- PrivilegeNotHeldException.cs
- GridViewEditEventArgs.cs
- _RequestCacheProtocol.cs
- IPGlobalProperties.cs
- Number.cs
- ObservableCollection.cs
- SplashScreenNativeMethods.cs
- EndpointAddress.cs
- ImageAutomationPeer.cs
- Helpers.cs
- TextEditorTyping.cs
- PersonalizationEntry.cs
- OraclePermissionAttribute.cs
- EventBuilder.cs
- XmlWrappingReader.cs
- ContentPlaceHolder.cs
- LinearQuaternionKeyFrame.cs
- BuildManager.cs
- HMACSHA384.cs
- OutputCacheSection.cs
- ExternalException.cs
- MailDefinition.cs
- SHA1.cs
- ResetableIterator.cs
- CodeMemberField.cs
- ServerIdentity.cs
- LicFileLicenseProvider.cs
- LoginName.cs
- OdbcDataAdapter.cs
- SqlNodeTypeOperators.cs
- DoubleCollectionConverter.cs
- HtmlElementErrorEventArgs.cs
- HttpRequestCacheValidator.cs
- PenContext.cs
- ADConnectionHelper.cs
- ParseNumbers.cs
- SqlDataSource.cs
- NumberFormatter.cs
- RegionData.cs
- RangeValidator.cs
- WebPartsPersonalizationAuthorization.cs
- UpdatePanel.cs
- SystemNetworkInterface.cs
- NumberFormatInfo.cs
- CodePageUtils.cs
- PointValueSerializer.cs
- ThreadStartException.cs
- RequestResizeEvent.cs
- SchemaTypeEmitter.cs
- RectangleConverter.cs
- UnicodeEncoding.cs
- StateMachine.cs
- DataServices.cs
- GroupByExpressionRewriter.cs
- AnnotationAuthorChangedEventArgs.cs
- HttpClientProtocol.cs
- safesecurityhelperavalon.cs
- SelectionPatternIdentifiers.cs
- Int32KeyFrameCollection.cs
- ParamArrayAttribute.cs
- BookmarkInfo.cs
- MdbDataFileEditor.cs
- ClonableStack.cs
- DomainUpDown.cs
- AudioFormatConverter.cs
- TextParagraph.cs
- PersistenceTypeAttribute.cs