Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- BufferedGraphics.cs
- WorkflowPageSetupDialog.cs
- EdmToObjectNamespaceMap.cs
- DataColumnChangeEvent.cs
- InvalidPrinterException.cs
- CachedBitmap.cs
- ExceptionHelpers.cs
- Span.cs
- PropVariant.cs
- WindowsAuthenticationEventArgs.cs
- ToolStripMenuItem.cs
- IfAction.cs
- ManagementQuery.cs
- StdRegProviderWrapper.cs
- ConfigUtil.cs
- AnimationStorage.cs
- RectAnimationUsingKeyFrames.cs
- EdgeModeValidation.cs
- WrappedReader.cs
- RoleGroupCollection.cs
- VisemeEventArgs.cs
- CommandEventArgs.cs
- OracleSqlParser.cs
- WebBrowserDocumentCompletedEventHandler.cs
- RecipientInfo.cs
- XmlDocumentSerializer.cs
- X509Chain.cs
- XmlSchema.cs
- EmptyImpersonationContext.cs
- EncoderReplacementFallback.cs
- XmlAttributeProperties.cs
- DelegateArgument.cs
- ToolCreatedEventArgs.cs
- FormsAuthenticationConfiguration.cs
- ParserHooks.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- DescriptionAttribute.cs
- PingOptions.cs
- SafeSecurityHelper.cs
- StartUpEventArgs.cs
- IEnumerable.cs
- MatrixKeyFrameCollection.cs
- ConfigurationStrings.cs
- ListViewSortEventArgs.cs
- TextServicesPropertyRanges.cs
- Quack.cs
- MruCache.cs
- ObjectDataSource.cs
- RuntimeConfig.cs
- AnimatedTypeHelpers.cs
- DesignUtil.cs
- TemplateBindingExtensionConverter.cs
- ResourceDisplayNameAttribute.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- ContainerUtilities.cs
- Lock.cs
- GridViewRow.cs
- ImageCollectionCodeDomSerializer.cs
- SqlTopReducer.cs
- ScaleTransform3D.cs
- WindowsIPAddress.cs
- Stack.cs
- MetadataExchangeBindings.cs
- CounterSample.cs
- SiteMapHierarchicalDataSourceView.cs
- SymmetricAlgorithm.cs
- RegisteredScript.cs
- Util.cs
- CloudCollection.cs
- TextEditorContextMenu.cs
- Classification.cs
- BookmarkResumptionRecord.cs
- ParseHttpDate.cs
- DateTimeUtil.cs
- SafeSecurityHandles.cs
- IndentTextWriter.cs
- FamilyTypeface.cs
- DelayedRegex.cs
- SqlDataSourceCache.cs
- BuildResultCache.cs
- NamespaceImport.cs
- BamlLocalizableResource.cs
- SchemaNames.cs
- ThemeDirectoryCompiler.cs
- TabletDeviceInfo.cs
- Reference.cs
- Symbol.cs
- Vector3D.cs
- CodeArgumentReferenceExpression.cs
- BinaryMethodMessage.cs
- Accessible.cs
- webbrowsersite.cs
- UserValidatedEventArgs.cs
- BaseAddressElement.cs
- ProcessInfo.cs
- XmlNavigatorFilter.cs
- BaseParser.cs
- EmbeddedMailObject.cs
- WindowsSysHeader.cs
- ColumnMap.cs