Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- GestureRecognitionResult.cs
- TranslateTransform3D.cs
- DesignerDataTable.cs
- IndependentAnimationStorage.cs
- ContextStack.cs
- SqlBinder.cs
- FormatControl.cs
- WebScriptMetadataMessage.cs
- SchemaImporterExtension.cs
- NodeInfo.cs
- Environment.cs
- QuadTree.cs
- DbConnectionClosed.cs
- DockAndAnchorLayout.cs
- HierarchicalDataBoundControlAdapter.cs
- XmlSortKeyAccumulator.cs
- MailMessage.cs
- DeflateEmulationStream.cs
- KeyValuePairs.cs
- GridViewRowEventArgs.cs
- EventRouteFactory.cs
- handlecollector.cs
- FormatVersion.cs
- DeflateInput.cs
- LowerCaseStringConverter.cs
- ParagraphVisual.cs
- FrugalList.cs
- AdRotator.cs
- ResXBuildProvider.cs
- XPathNavigatorReader.cs
- BatchParser.cs
- RSAPKCS1KeyExchangeFormatter.cs
- ProviderCollection.cs
- PeerService.cs
- SiteIdentityPermission.cs
- MustUnderstandBehavior.cs
- DesignSurfaceCollection.cs
- PreviousTrackingServiceAttribute.cs
- XNodeNavigator.cs
- UnsafeNativeMethods.cs
- KnownBoxes.cs
- SafeMemoryMappedViewHandle.cs
- ImageCodecInfo.cs
- DataGridViewCellCollection.cs
- DelayedRegex.cs
- ToolBarButton.cs
- JsonUriDataContract.cs
- TemplateKeyConverter.cs
- SecurityProtocolFactory.cs
- ExpressionValueEditor.cs
- DataGridViewCellStyleEditor.cs
- TouchesCapturedWithinProperty.cs
- SoapCodeExporter.cs
- HandlerMappingMemo.cs
- TraceLog.cs
- DropSourceBehavior.cs
- AuthenticationModeHelper.cs
- ConnectionManagementElementCollection.cs
- Deflater.cs
- WebPartCollection.cs
- PolyLineSegment.cs
- PatternMatcher.cs
- XmlDataProvider.cs
- RelationalExpressions.cs
- TypedTableBaseExtensions.cs
- DesignTimeParseData.cs
- SQLMoney.cs
- CompressedStack.cs
- BasePropertyDescriptor.cs
- basevalidator.cs
- DashStyle.cs
- TextTabProperties.cs
- VerificationAttribute.cs
- MSHTMLHost.cs
- TemplateBindingExpressionConverter.cs
- ReflectionServiceProvider.cs
- ClientBuildManagerCallback.cs
- AutomationPatternInfo.cs
- UnicastIPAddressInformationCollection.cs
- Function.cs
- CallTemplateAction.cs
- TextTreeUndo.cs
- CryptoApi.cs
- ObjectListGeneralPage.cs
- BinaryWriter.cs
- AutomationPatternInfo.cs
- TextModifier.cs
- DockPatternIdentifiers.cs
- WebBrowserPermission.cs
- TableAdapterManagerNameHandler.cs
- InfoCardArgumentException.cs
- TransactionsSectionGroup.cs
- DiagnosticsConfiguration.cs
- TemplateBuilder.cs
- ToggleProviderWrapper.cs
- DoubleAnimationBase.cs
- SQLChars.cs
- SessionSwitchEventArgs.cs
- Char.cs
- RewritingPass.cs