Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TreeViewAutomationPeer.cs
- CompModSwitches.cs
- TreeNodeStyleCollectionEditor.cs
- BitStack.cs
- StateManagedCollection.cs
- EmptyStringExpandableObjectConverter.cs
- TableDetailsCollection.cs
- ClientRuntimeConfig.cs
- MarginsConverter.cs
- AbandonedMutexException.cs
- SoapAttributeAttribute.cs
- Int16Storage.cs
- StreamResourceInfo.cs
- ParserContext.cs
- EdmPropertyAttribute.cs
- Glyph.cs
- SmiEventStream.cs
- ComAdminWrapper.cs
- ItemDragEvent.cs
- TextRangeProviderWrapper.cs
- StreamInfo.cs
- FormsAuthenticationTicket.cs
- SynchronizedInputAdaptor.cs
- OleDbParameterCollection.cs
- DataGridViewRowHeaderCell.cs
- SqlDataSourceCache.cs
- x509utils.cs
- AnnouncementEndpointElement.cs
- EastAsianLunisolarCalendar.cs
- TablePattern.cs
- DefinitionUpdate.cs
- ContractValidationHelper.cs
- WsdlInspector.cs
- EntityDataSourceReferenceGroup.cs
- ItemTypeToolStripMenuItem.cs
- Win32Native.cs
- OrthographicCamera.cs
- AutomationPropertyInfo.cs
- EditingCommands.cs
- MemoryMappedViewStream.cs
- SingleTagSectionHandler.cs
- DifferencingCollection.cs
- Utils.cs
- VScrollProperties.cs
- AsyncPostBackTrigger.cs
- GenerateHelper.cs
- HttpWriter.cs
- Operand.cs
- SystemInformation.cs
- TrackingValidationObjectDictionary.cs
- EntityParameter.cs
- MatrixCamera.cs
- SessionStateModule.cs
- MatrixCamera.cs
- odbcmetadatacollectionnames.cs
- SharedPersonalizationStateInfo.cs
- PerformanceCounterManager.cs
- DataContractAttribute.cs
- OrderedDictionary.cs
- Registry.cs
- IndexerNameAttribute.cs
- _HelperAsyncResults.cs
- TextEditorTyping.cs
- EventArgs.cs
- LeaseManager.cs
- FormClosingEvent.cs
- BinaryUtilClasses.cs
- UserNameSecurityTokenAuthenticator.cs
- ChangeNode.cs
- PageRequestManager.cs
- AudioBase.cs
- DbProviderConfigurationHandler.cs
- EditorReuseAttribute.cs
- SecureEnvironment.cs
- TriggerCollection.cs
- ipaddressinformationcollection.cs
- CodeDOMProvider.cs
- DynamicMethod.cs
- OdbcEnvironment.cs
- Columns.cs
- Point4DValueSerializer.cs
- RepeaterItemEventArgs.cs
- DataRowChangeEvent.cs
- FileDialogCustomPlacesCollection.cs
- SimpleBitVector32.cs
- XmlBufferReader.cs
- EventMap.cs
- OleDbTransaction.cs
- BindingMemberInfo.cs
- RegexStringValidatorAttribute.cs
- _HTTPDateParse.cs
- AnimationClockResource.cs
- COM2ColorConverter.cs
- ExplicitDiscriminatorMap.cs
- LayoutTableCell.cs
- LassoSelectionBehavior.cs
- Point3D.cs
- SplineKeyFrames.cs
- XDeferredAxisSource.cs
- PrintControllerWithStatusDialog.cs