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
- ServiceTimeoutsElement.cs
- Transform3D.cs
- FixedTextPointer.cs
- MsmqBindingBase.cs
- XamlPathDataSerializer.cs
- RightsManagementEncryptedStream.cs
- CanExecuteRoutedEventArgs.cs
- ObjectListGeneralPage.cs
- _UriTypeConverter.cs
- Vector3DCollection.cs
- versioninfo.cs
- DeviceSpecificDesigner.cs
- NonClientArea.cs
- BitmapData.cs
- FrameDimension.cs
- TCPClient.cs
- DeclaredTypeElement.cs
- SQLChars.cs
- LineProperties.cs
- ConfigPathUtility.cs
- EventWaitHandleSecurity.cs
- XmlCharacterData.cs
- DataGridPageChangedEventArgs.cs
- TextLine.cs
- XPathSingletonIterator.cs
- UnsupportedPolicyOptionsException.cs
- IODescriptionAttribute.cs
- PlatformNotSupportedException.cs
- UnsafeNativeMethods.cs
- DispatcherHookEventArgs.cs
- PropertyPathWorker.cs
- OutOfMemoryException.cs
- TiffBitmapDecoder.cs
- SafeNativeMemoryHandle.cs
- DependencySource.cs
- ContentValidator.cs
- DataServiceClientException.cs
- HijriCalendar.cs
- EmptyReadOnlyDictionaryInternal.cs
- nulltextnavigator.cs
- WorkflowViewService.cs
- SQLInt64Storage.cs
- BypassElementCollection.cs
- querybuilder.cs
- PageVisual.cs
- FastEncoderWindow.cs
- ElapsedEventArgs.cs
- Win32.cs
- X509Certificate.cs
- MobileControlsSectionHelper.cs
- MdiWindowListStrip.cs
- TextEffect.cs
- ProfilePropertyNameValidator.cs
- NameGenerator.cs
- CounterCreationDataCollection.cs
- CompositeFontInfo.cs
- DataStreams.cs
- RawStylusInputCustomData.cs
- Context.cs
- Descriptor.cs
- WindowCollection.cs
- _NestedMultipleAsyncResult.cs
- PackageRelationship.cs
- TextWriterEngine.cs
- Util.cs
- FormatPage.cs
- GPRECTF.cs
- HatchBrush.cs
- SplineQuaternionKeyFrame.cs
- RegexReplacement.cs
- BooleanKeyFrameCollection.cs
- ApplicationGesture.cs
- OdbcConnection.cs
- SessionStateModule.cs
- RubberbandSelector.cs
- XPathExpr.cs
- DataRowCollection.cs
- RoutedPropertyChangedEventArgs.cs
- TextRunProperties.cs
- DataGridViewCellFormattingEventArgs.cs
- AttributeCollection.cs
- GetPageNumberCompletedEventArgs.cs
- InkCanvasInnerCanvas.cs
- RegexInterpreter.cs
- TextElementEditingBehaviorAttribute.cs
- EmptyEnumerator.cs
- Listen.cs
- ImageSourceTypeConverter.cs
- DataControlField.cs
- XmlDocumentType.cs
- MD5.cs
- DeviceSpecificChoiceCollection.cs
- ProfileService.cs
- SubMenuStyle.cs
- SqlDataSourceCommandEventArgs.cs
- WebConfigurationHost.cs
- DataGridItemAutomationPeer.cs
- SqlCommandBuilder.cs
- TabControlEvent.cs
- CodeExpressionStatement.cs