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
- DetailsViewInsertEventArgs.cs
- IISMapPath.cs
- Int32KeyFrameCollection.cs
- Label.cs
- PopupRootAutomationPeer.cs
- ProjectionCamera.cs
- ReadOnlyDictionary.cs
- TextParagraphCache.cs
- TextTabProperties.cs
- ComponentChangingEvent.cs
- FontUnitConverter.cs
- RectAnimation.cs
- EntityClientCacheKey.cs
- RegionInfo.cs
- NumericUpDown.cs
- Int16Converter.cs
- ExclusiveHandleList.cs
- FontStretches.cs
- SortedList.cs
- MetabaseServerConfig.cs
- SpeakCompletedEventArgs.cs
- DataTableCollection.cs
- Section.cs
- ProjectionPathSegment.cs
- MsmqBindingFilter.cs
- OutOfProcStateClientManager.cs
- CommentEmitter.cs
- CultureSpecificStringDictionary.cs
- DateTimePicker.cs
- input.cs
- XmlSchemaAll.cs
- AssemblyHash.cs
- DesignOnlyAttribute.cs
- AttributeCollection.cs
- DrawingImage.cs
- SafeNativeMethodsOther.cs
- IISUnsafeMethods.cs
- DeploymentSection.cs
- ResourceDescriptionAttribute.cs
- fixedPageContentExtractor.cs
- LinqDataSourceDeleteEventArgs.cs
- EventManager.cs
- CompositeKey.cs
- Socket.cs
- Quaternion.cs
- SoapServerMethod.cs
- BookmarkScopeManager.cs
- PropertyCondition.cs
- GeneralTransform2DTo3DTo2D.cs
- EndpointBehaviorElement.cs
- WizardPanelChangingEventArgs.cs
- DirectoryRootQuery.cs
- BufferModesCollection.cs
- ToolStripContainer.cs
- EditorPartCollection.cs
- RenderingBiasValidation.cs
- PropertyTabAttribute.cs
- CodeSnippetStatement.cs
- ImportContext.cs
- xml.cs
- LambdaCompiler.ControlFlow.cs
- translator.cs
- WebPartConnectionsCancelEventArgs.cs
- DCSafeHandle.cs
- PasswordDeriveBytes.cs
- BinaryConverter.cs
- TableDetailsCollection.cs
- OleAutBinder.cs
- SR.Designer.cs
- Utils.cs
- ListChangedEventArgs.cs
- SamlSubjectStatement.cs
- DBDataPermissionAttribute.cs
- RenderingEventArgs.cs
- AnnotationResourceChangedEventArgs.cs
- DBAsyncResult.cs
- SimplePropertyEntry.cs
- Message.cs
- ToolStripLocationCancelEventArgs.cs
- CoreSwitches.cs
- WebPartConnectionsCancelVerb.cs
- HwndTarget.cs
- DocumentReferenceCollection.cs
- WmlObjectListAdapter.cs
- OleDbStruct.cs
- ExpressionParser.cs
- IImplicitResourceProvider.cs
- BaseDataBoundControl.cs
- UserControlParser.cs
- _Win32.cs
- EnlistmentState.cs
- SubclassTypeValidatorAttribute.cs
- Expander.cs
- Tracer.cs
- MeasurementDCInfo.cs
- FixUp.cs
- BitmapPalette.cs
- XmlSerializableServices.cs
- Line.cs
- EdmToObjectNamespaceMap.cs