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
- StateRuntime.cs
- XPathNavigatorReader.cs
- RelationshipEntry.cs
- DynamicEntity.cs
- CodeAttributeArgumentCollection.cs
- DataGridViewButtonColumn.cs
- KeyboardNavigation.cs
- CapabilitiesState.cs
- CharacterHit.cs
- InputLanguageEventArgs.cs
- RegistryDataKey.cs
- ObjectHandle.cs
- CompilationUtil.cs
- XmlElementAttribute.cs
- Decimal.cs
- Stylesheet.cs
- RawStylusSystemGestureInputReport.cs
- DesignTimeParseData.cs
- CacheMemory.cs
- ArgumentException.cs
- EntityCommandDefinition.cs
- HtmlInputFile.cs
- ExpressionEditorAttribute.cs
- MenuItem.cs
- ComponentEvent.cs
- DetailsViewDeletedEventArgs.cs
- ResXDataNode.cs
- EncoderParameter.cs
- ToolStripLocationCancelEventArgs.cs
- MessageSmuggler.cs
- Logging.cs
- ResourcesBuildProvider.cs
- DictionaryKeyPropertyAttribute.cs
- ProcessManager.cs
- SafeCloseHandleCritical.cs
- TypeResolvingOptions.cs
- FileDetails.cs
- ProfileGroupSettings.cs
- ParsedAttributeCollection.cs
- WebBrowserBase.cs
- ThrowHelper.cs
- CannotUnloadAppDomainException.cs
- JsonReader.cs
- XmlHierarchicalEnumerable.cs
- StylusTip.cs
- ImageUrlEditor.cs
- ThreadBehavior.cs
- DataGridViewComboBoxColumnDesigner.cs
- PkcsMisc.cs
- DecoratedNameAttribute.cs
- DataListItemEventArgs.cs
- WebPartConnectionsCancelEventArgs.cs
- ValuePatternIdentifiers.cs
- RegexMatchCollection.cs
- DoubleAnimationUsingPath.cs
- WebPartUserCapability.cs
- BitmapEffectDrawingContent.cs
- TextBoxAutoCompleteSourceConverter.cs
- XPathNode.cs
- MonthCalendar.cs
- TextSelection.cs
- ObjectDataProvider.cs
- TimeSpanValidator.cs
- DocumentXPathNavigator.cs
- ReadOnlyHierarchicalDataSourceView.cs
- AsymmetricKeyExchangeFormatter.cs
- SiteOfOriginContainer.cs
- FilterableData.cs
- EnumerableValidator.cs
- XmlText.cs
- DateTimeOffsetStorage.cs
- PropertyStore.cs
- TailCallAnalyzer.cs
- ECDsa.cs
- WindowsGraphicsCacheManager.cs
- XmlSchemaValidator.cs
- WindowsGraphics.cs
- ComponentEvent.cs
- WebScriptServiceHostFactory.cs
- InkCanvas.cs
- SettingsPropertyValue.cs
- DtdParser.cs
- Documentation.cs
- VBIdentifierDesigner.xaml.cs
- ResourceSet.cs
- XmlExpressionDumper.cs
- Matrix3DConverter.cs
- UniqueIdentifierService.cs
- MemberInfoSerializationHolder.cs
- AuthenticationModuleElementCollection.cs
- translator.cs
- ChannelFactoryBase.cs
- SocketAddress.cs
- FieldNameLookup.cs
- DiscreteKeyFrames.cs
- BinaryCommonClasses.cs
- XmlEventCache.cs
- KeyInstance.cs
- _UncName.cs
- SafeNativeMethods.cs