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
- EntityStoreSchemaGenerator.cs
- ListItemConverter.cs
- InvalidDataException.cs
- EdmEntityTypeAttribute.cs
- CellRelation.cs
- ProtocolsConfiguration.cs
- KeyGestureConverter.cs
- UnauthorizedWebPart.cs
- FrameworkContentElementAutomationPeer.cs
- NumberSubstitution.cs
- DSASignatureFormatter.cs
- ActivityExecutionContext.cs
- ACE.cs
- FontFaceLayoutInfo.cs
- RuntimeWrappedException.cs
- TheQuery.cs
- WebPartEventArgs.cs
- FloatUtil.cs
- StdValidatorsAndConverters.cs
- ValidatingPropertiesEventArgs.cs
- Scanner.cs
- DefaultHttpHandler.cs
- IPGlobalProperties.cs
- HttpCachePolicyElement.cs
- QueryConverter.cs
- FaultDescription.cs
- MissingMethodException.cs
- SubMenuStyleCollection.cs
- DataGridViewCheckBoxColumn.cs
- HyperLink.cs
- Util.cs
- SqlDataSourceCommandEventArgs.cs
- OleServicesContext.cs
- ObjectPersistData.cs
- LinkedResource.cs
- IPipelineRuntime.cs
- SqlCacheDependencyDatabaseCollection.cs
- CommandConverter.cs
- EntityDataSourceWizardForm.cs
- ButtonFlatAdapter.cs
- BuildProviderAppliesToAttribute.cs
- ColorPalette.cs
- counter.cs
- DefinitionBase.cs
- FontDifferentiator.cs
- ControlBuilder.cs
- SpecialFolderEnumConverter.cs
- CatalogZone.cs
- CodePageEncoding.cs
- FieldInfo.cs
- PrimitiveXmlSerializers.cs
- ServicePointManager.cs
- XPathParser.cs
- Int64Converter.cs
- HandlerBase.cs
- Reference.cs
- DataGridViewTextBoxColumn.cs
- ScalarConstant.cs
- FormViewModeEventArgs.cs
- IDQuery.cs
- OleDbWrapper.cs
- ObjectAnimationBase.cs
- DataListItemCollection.cs
- FixedTextView.cs
- UpnEndpointIdentityExtension.cs
- ValueType.cs
- NeutralResourcesLanguageAttribute.cs
- IdentityHolder.cs
- EntityAdapter.cs
- XamlBrushSerializer.cs
- LinkedResource.cs
- XmlSiteMapProvider.cs
- WmlFormAdapter.cs
- QilStrConcat.cs
- KnownTypeHelper.cs
- DataServiceEntityAttribute.cs
- MouseButton.cs
- ListItemCollection.cs
- VScrollProperties.cs
- Double.cs
- _AutoWebProxyScriptWrapper.cs
- ParameterElement.cs
- Match.cs
- GridViewRowPresenterBase.cs
- BrushMappingModeValidation.cs
- ReliableMessagingVersion.cs
- StreamSecurityUpgradeAcceptorBase.cs
- WeakReferenceKey.cs
- WebPartMenuStyle.cs
- AvTraceFormat.cs
- EventsTab.cs
- WizardPanel.cs
- RenderContext.cs
- DesignerHierarchicalDataSourceView.cs
- QilXmlReader.cs
- Validator.cs
- ClientRuntimeConfig.cs
- RegionInfo.cs
- WindowsListViewItemCheckBox.cs
- RedistVersionInfo.cs