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
- ProfilePropertyNameValidator.cs
- SqlStream.cs
- GlobalEventManager.cs
- EventWaitHandle.cs
- CompatibleIComparer.cs
- LineServicesRun.cs
- FormCollection.cs
- ControlBuilder.cs
- ClientApiGenerator.cs
- HandlerBase.cs
- FilteredXmlReader.cs
- GridViewDeletedEventArgs.cs
- TimeSpanSecondsConverter.cs
- DataKey.cs
- DataGridColumnHeadersPresenter.cs
- AmbientLight.cs
- VolatileResourceManager.cs
- XNameTypeConverter.cs
- DropShadowEffect.cs
- XpsStructure.cs
- Part.cs
- EntityConnection.cs
- SurrogateEncoder.cs
- ListBox.cs
- DrawingState.cs
- Button.cs
- WebServiceMethodData.cs
- RightsManagementInformation.cs
- WindowsListViewSubItem.cs
- XamlWrapperReaders.cs
- XPathNodePointer.cs
- StreamHelper.cs
- ToolStripComboBox.cs
- FontStyle.cs
- IUnknownConstantAttribute.cs
- XmlTextReaderImplHelpers.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- IItemProperties.cs
- PointAnimationBase.cs
- BaseParser.cs
- StringComparer.cs
- XmlValueConverter.cs
- filewebrequest.cs
- CssStyleCollection.cs
- RenderContext.cs
- XmlAttribute.cs
- _LoggingObject.cs
- WebBrowserHelper.cs
- CuspData.cs
- SynchronizingStream.cs
- MulticastIPAddressInformationCollection.cs
- HighlightVisual.cs
- AlternationConverter.cs
- TagMapInfo.cs
- SessionStateModule.cs
- IndexedEnumerable.cs
- AuthenticationModulesSection.cs
- GenericArgumentsUpdater.cs
- SafeProcessHandle.cs
- BaseDataBoundControl.cs
- ScriptManagerProxy.cs
- Decimal.cs
- DesignerOptionService.cs
- DataGridViewRowsAddedEventArgs.cs
- ScriptResourceInfo.cs
- SeparatorAutomationPeer.cs
- PropertyMap.cs
- FixedSOMImage.cs
- UnsettableComboBox.cs
- OracleEncoding.cs
- ValidatorAttribute.cs
- WebServiceMethodData.cs
- AppDomainManager.cs
- HitTestParameters3D.cs
- XmlElementAttributes.cs
- StringExpressionSet.cs
- EncryptedPackageFilter.cs
- Version.cs
- ListSortDescriptionCollection.cs
- EditCommandColumn.cs
- RsaSecurityKey.cs
- QueryHandler.cs
- CookielessHelper.cs
- ManagedFilter.cs
- DataBindingCollectionEditor.cs
- SerialPinChanges.cs
- MD5.cs
- DecoderFallback.cs
- BamlLocalizer.cs
- RelationshipNavigation.cs
- Cloud.cs
- Literal.cs
- DataFieldConverter.cs
- QilReplaceVisitor.cs
- DataGridViewTextBoxCell.cs
- ServiceErrorHandler.cs
- XPathException.cs
- DoubleAnimationClockResource.cs
- HtmlWindowCollection.cs
- WebPartCatalogCloseVerb.cs