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
- ViewKeyConstraint.cs
- CompilationLock.cs
- LassoSelectionBehavior.cs
- InstallerTypeAttribute.cs
- AnnotationService.cs
- Attribute.cs
- RtfToXamlReader.cs
- UnsafeNativeMethods.cs
- ScrollItemPattern.cs
- XmlSchemaCompilationSettings.cs
- ProcessThreadDesigner.cs
- KeyEvent.cs
- webclient.cs
- SynchronizedMessageSource.cs
- ComContractElement.cs
- EnumMember.cs
- PageStatePersister.cs
- RequiredFieldValidator.cs
- MediaContext.cs
- MobileUserControlDesigner.cs
- XsltLibrary.cs
- TypeFieldSchema.cs
- ServiceDocumentFormatter.cs
- VisualTreeUtils.cs
- _RequestCacheProtocol.cs
- UIAgentAsyncEndRequest.cs
- RoleGroup.cs
- Matrix3DConverter.cs
- WeakHashtable.cs
- XmlSchemaSimpleTypeUnion.cs
- DataObjectFieldAttribute.cs
- GridItemPattern.cs
- SpinLock.cs
- OLEDB_Util.cs
- OutOfProcStateClientManager.cs
- ScrollProviderWrapper.cs
- DateTimeConverter.cs
- Rotation3DAnimationUsingKeyFrames.cs
- ComponentResourceKeyConverter.cs
- BaseTransportHeaders.cs
- MexHttpBindingElement.cs
- InputGestureCollection.cs
- DataRelationCollection.cs
- XmlHelper.cs
- GlobalEventManager.cs
- XmlNodeReader.cs
- XmlSchemaImporter.cs
- TransformCryptoHandle.cs
- SHA384Managed.cs
- FillErrorEventArgs.cs
- CodeSubDirectoriesCollection.cs
- _ChunkParse.cs
- WorkflowInstanceExtensionManager.cs
- CircleHotSpot.cs
- Thread.cs
- TextPointer.cs
- BuilderInfo.cs
- RSAPKCS1SignatureFormatter.cs
- MouseOverProperty.cs
- TextEffect.cs
- IdleTimeoutMonitor.cs
- RowBinding.cs
- Brushes.cs
- EntityDataSourceValidationException.cs
- BitmapEffectrendercontext.cs
- IsolatedStorageFilePermission.cs
- SerTrace.cs
- ComPlusDiagnosticTraceSchemas.cs
- Parameter.cs
- Overlapped.cs
- WebOperationContext.cs
- PointF.cs
- WebScriptEnablingBehavior.cs
- ExpandCollapsePattern.cs
- Literal.cs
- WebPartsSection.cs
- AnonymousIdentificationSection.cs
- NavigatorOutput.cs
- ProfileManager.cs
- TypedRowGenerator.cs
- HMAC.cs
- HtmlSelect.cs
- DropSource.cs
- XmlEncodedRawTextWriter.cs
- TextBoxAutomationPeer.cs
- FormatVersion.cs
- DataGridViewSelectedRowCollection.cs
- Quaternion.cs
- SqlError.cs
- PreviewPageInfo.cs
- ComboBoxRenderer.cs
- EntityContainerEntitySet.cs
- XPathNavigatorReader.cs
- GridViewAutomationPeer.cs
- UserValidatedEventArgs.cs
- ArrayElementGridEntry.cs
- TableCellAutomationPeer.cs
- NativeMethods.cs
- OleDbConnectionFactory.cs
- CommentGlyph.cs