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
- Identifier.cs
- DefaultShape.cs
- ListBindingHelper.cs
- MaterializeFromAtom.cs
- ConfigurationSectionCollection.cs
- TagPrefixInfo.cs
- BinaryObjectReader.cs
- FastEncoderWindow.cs
- CurrentTimeZone.cs
- XmlMtomReader.cs
- QilTargetType.cs
- EventLogConfiguration.cs
- CodeAttributeDeclarationCollection.cs
- ScopedMessagePartSpecification.cs
- HttpPostedFile.cs
- DefinitionBase.cs
- OperationInfo.cs
- SoapSchemaMember.cs
- InputBinding.cs
- SynchronizationContext.cs
- QualificationDataItem.cs
- FontUnit.cs
- UriExt.cs
- CompileLiteralTextParser.cs
- EncoderParameter.cs
- AccessDataSource.cs
- ConstraintConverter.cs
- QueryStack.cs
- DesignerLoader.cs
- EncryptedReference.cs
- ADMembershipProvider.cs
- StaticDataManager.cs
- TagPrefixAttribute.cs
- EventWaitHandleSecurity.cs
- SqlGatherConsumedAliases.cs
- XmlAttribute.cs
- GlyphTypeface.cs
- ActivityExecutorDelegateInfo.cs
- ComboBoxDesigner.cs
- ServiceAppDomainAssociationProvider.cs
- Empty.cs
- XmlSchemaAttribute.cs
- SafeFileMappingHandle.cs
- XmlSchemaAnnotation.cs
- SafeRegistryKey.cs
- CodeMemberField.cs
- DataGridViewElement.cs
- DataGridViewRowConverter.cs
- MULTI_QI.cs
- FileSecurity.cs
- DataTableReader.cs
- AppLevelCompilationSectionCache.cs
- FontNamesConverter.cs
- EtwProvider.cs
- Size.cs
- MetadataArtifactLoaderComposite.cs
- DuplicateWaitObjectException.cs
- CollectionBuilder.cs
- SqlDeflator.cs
- SQLByte.cs
- Predicate.cs
- DataGridCheckBoxColumn.cs
- ClientViaElement.cs
- XmlNodeList.cs
- DataGridViewToolTip.cs
- ParameterBuilder.cs
- UdpMessageProperty.cs
- WindowsUpDown.cs
- FlowNode.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- XamlPoint3DCollectionSerializer.cs
- ToolStripScrollButton.cs
- MetadataReference.cs
- ExtensionFile.cs
- ForwardPositionQuery.cs
- Int16.cs
- ComplusTypeValidator.cs
- Renderer.cs
- ResourcePermissionBaseEntry.cs
- ConnectionInterfaceCollection.cs
- Guid.cs
- BufferModeSettings.cs
- ConnectionStringSettings.cs
- RIPEMD160Managed.cs
- RoutedEventArgs.cs
- FlowLayoutSettings.cs
- SqlAggregateChecker.cs
- RightsManagementInformation.cs
- EnumConverter.cs
- TraceUtility.cs
- EntityCommandCompilationException.cs
- CompilerTypeWithParams.cs
- BypassElement.cs
- SmiTypedGetterSetter.cs
- XmlElementAttribute.cs
- documentsequencetextcontainer.cs
- X509Chain.cs
- cookiecollection.cs
- _DigestClient.cs
- StoreContentChangedEventArgs.cs