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
- AnchoredBlock.cs
- CompositeKey.cs
- XmlWriter.cs
- MenuCommandService.cs
- KnowledgeBase.cs
- LowerCaseStringConverter.cs
- Timer.cs
- Permission.cs
- MarkupExtensionSerializer.cs
- Typography.cs
- iisPickupDirectory.cs
- XmlAttributeAttribute.cs
- future.cs
- RegexParser.cs
- XmlSchemaElement.cs
- IdlingCommunicationPool.cs
- ContractCodeDomInfo.cs
- TimelineGroup.cs
- TdsParameterSetter.cs
- ExpressionBinding.cs
- TreeNodeCollectionEditor.cs
- SafeReversePInvokeHandle.cs
- SkewTransform.cs
- LinkButton.cs
- PrincipalPermission.cs
- DesignerCategoryAttribute.cs
- BulletedListEventArgs.cs
- DatatypeImplementation.cs
- ByteAnimationBase.cs
- HebrewNumber.cs
- BCLDebug.cs
- SqlProvider.cs
- ZoneIdentityPermission.cs
- ReaderOutput.cs
- CreateDataSourceDialog.cs
- AudioFormatConverter.cs
- UpdateTranslator.cs
- HandleInitializationContext.cs
- WizardForm.cs
- RowParagraph.cs
- ProfileProvider.cs
- Exception.cs
- DataGridViewHitTestInfo.cs
- VariableValue.cs
- ToolStripContentPanelRenderEventArgs.cs
- QilGenerator.cs
- EntitySqlQueryBuilder.cs
- ReadWriteObjectLock.cs
- Image.cs
- AttachedPropertyBrowsableAttribute.cs
- DependencyProperty.cs
- HtmlEmptyTagControlBuilder.cs
- TrayIconDesigner.cs
- ItemDragEvent.cs
- RegistryPermission.cs
- MouseEventArgs.cs
- Converter.cs
- XslTransform.cs
- Table.cs
- XPathExpr.cs
- RectangleF.cs
- MimeWriter.cs
- RevocationPoint.cs
- WebPartsPersonalization.cs
- BuildProvidersCompiler.cs
- XmlIterators.cs
- ToolStripPanel.cs
- VarRefManager.cs
- CalendarTable.cs
- XmlNodeChangedEventArgs.cs
- PrintDialog.cs
- MonikerSyntaxException.cs
- RadioButton.cs
- ConfigXmlAttribute.cs
- HtmlPanelAdapter.cs
- ScrollData.cs
- ActivityExecutionFilter.cs
- MasterPage.cs
- ClientCredentials.cs
- SqlProcedureAttribute.cs
- XmlILAnnotation.cs
- QueueAccessMode.cs
- SafeLocalMemHandle.cs
- VirtualPathProvider.cs
- WebRequestModuleElementCollection.cs
- ContainerTracking.cs
- XmlSerializationGeneratedCode.cs
- PtsPage.cs
- Error.cs
- TreeNode.cs
- DrawingImage.cs
- Logging.cs
- Condition.cs
- FrameworkContentElement.cs
- RtType.cs
- GrammarBuilderBase.cs
- DesignTable.cs
- NaturalLanguageHyphenator.cs
- URLString.cs
- DecimalAnimationBase.cs