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
- TimestampInformation.cs
- XmlNode.cs
- TypeNameConverter.cs
- DateTimeOffset.cs
- CodeAccessPermission.cs
- ResourceSet.cs
- SafeEventLogWriteHandle.cs
- DictionaryEditChange.cs
- CodeRegionDirective.cs
- CopyAction.cs
- CharEntityEncoderFallback.cs
- ThicknessConverter.cs
- ManagementNamedValueCollection.cs
- ListBoxAutomationPeer.cs
- Constraint.cs
- RequestQueryProcessor.cs
- WsatServiceCertificate.cs
- PairComparer.cs
- XmlNotation.cs
- GeneralTransform3DGroup.cs
- MessageSmuggler.cs
- StateMachineWorkflowInstance.cs
- ContextQuery.cs
- InstanceStore.cs
- EnumType.cs
- JapaneseCalendar.cs
- ProxyElement.cs
- DateTimeConverter.cs
- FigureParaClient.cs
- XmlSchemaException.cs
- ConfigurationManagerHelperFactory.cs
- ISO2022Encoding.cs
- FilteredDataSetHelper.cs
- HashUtility.cs
- XmlElementAttributes.cs
- TextBox.cs
- CaretElement.cs
- TabletCollection.cs
- DropDownList.cs
- TemplatedWizardStep.cs
- ChtmlSelectionListAdapter.cs
- SqlUtil.cs
- httpserverutility.cs
- SQLSingle.cs
- XmlQueryTypeFactory.cs
- SystemIPInterfaceProperties.cs
- HttpResponseBase.cs
- Rect.cs
- StateMachineDesignerPaint.cs
- DataGridViewComboBoxColumn.cs
- CharacterString.cs
- XmlSchemaSimpleTypeRestriction.cs
- WindowsGraphics2.cs
- ScrollableControl.cs
- SqlCrossApplyToCrossJoin.cs
- TypeToTreeConverter.cs
- FormsAuthentication.cs
- UndoManager.cs
- FontFamily.cs
- ExtendedPropertyCollection.cs
- Mapping.cs
- IdnElement.cs
- StrongName.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- TableLayoutStyleCollection.cs
- IdentifierElement.cs
- CodeArrayCreateExpression.cs
- DataGridViewSelectedCellCollection.cs
- ThemeInfoAttribute.cs
- ConfigurationConverterBase.cs
- XmlUnspecifiedAttribute.cs
- EntityUtil.cs
- Rectangle.cs
- TabletDevice.cs
- BamlBinaryWriter.cs
- EmptyEnumerator.cs
- DebugControllerThread.cs
- IssuanceLicense.cs
- ComboBox.cs
- PrinterSettings.cs
- ScalarRestriction.cs
- GetIndexBinder.cs
- RegisterResponseInfo.cs
- BufferedStream.cs
- DescendantQuery.cs
- HiddenFieldPageStatePersister.cs
- MenuItemBinding.cs
- BindingContext.cs
- FixedFlowMap.cs
- JsonQNameDataContract.cs
- PathFigureCollection.cs
- ConfigurationValidatorAttribute.cs
- AppDomainProtocolHandler.cs
- CompiledQueryCacheEntry.cs
- CodeAccessSecurityEngine.cs
- XpsResourcePolicy.cs
- WindowsScroll.cs
- FieldBuilder.cs
- Terminate.cs
- DataObjectAttribute.cs