Code:
/ DotNET / DotNET / 8.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
- ParseChildrenAsPropertiesAttribute.cs
- SafeViewOfFileHandle.cs
- StateItem.cs
- CompleteWizardStep.cs
- XmlNode.cs
- TextServicesCompartmentContext.cs
- PropertyChangedEventArgs.cs
- ThicknessAnimationUsingKeyFrames.cs
- RuntimeCompatibilityAttribute.cs
- TraceInternal.cs
- HttpInputStream.cs
- HttpConfigurationContext.cs
- Knowncolors.cs
- CompModSwitches.cs
- MaskPropertyEditor.cs
- SpellerInterop.cs
- HtmlForm.cs
- WriteableBitmap.cs
- SQLGuid.cs
- PropertySet.cs
- OleDbStruct.cs
- ThicknessAnimationUsingKeyFrames.cs
- PointCollection.cs
- Form.cs
- ButtonColumn.cs
- CompositeFontParser.cs
- Int64Converter.cs
- WebPartUserCapability.cs
- ReferenceConverter.cs
- RtfFormatStack.cs
- Floater.cs
- CompilationUtil.cs
- FolderBrowserDialog.cs
- ModifierKeysValueSerializer.cs
- PolicyManager.cs
- DataColumnCollection.cs
- ObjectTypeMapping.cs
- StorageMappingFragment.cs
- TabItemWrapperAutomationPeer.cs
- DateTimeFormat.cs
- DrawingContextDrawingContextWalker.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- GPPOINT.cs
- ClickablePoint.cs
- CodeTypeParameter.cs
- PageContentAsyncResult.cs
- CommandManager.cs
- ProfilePropertySettings.cs
- SortQuery.cs
- Peer.cs
- ImageListStreamer.cs
- TraceSection.cs
- ClosureBinding.cs
- Events.cs
- BrowserCapabilitiesCompiler.cs
- RangeExpression.cs
- CollectionChangeEventArgs.cs
- HttpListenerContext.cs
- COM2ICategorizePropertiesHandler.cs
- AttributedMetaModel.cs
- ProviderException.cs
- HttpListenerContext.cs
- ButtonColumn.cs
- PartialCachingControl.cs
- Hex.cs
- CodeAttributeDeclarationCollection.cs
- ServicePointManagerElement.cs
- CompiledIdentityConstraint.cs
- NonDualMessageSecurityOverHttp.cs
- DataGridSortCommandEventArgs.cs
- WebPartManager.cs
- PropertyDescriptorCollection.cs
- EditorZoneBase.cs
- HijriCalendar.cs
- GetPageCompletedEventArgs.cs
- UniformGrid.cs
- WindowsFormsSynchronizationContext.cs
- CuspData.cs
- ScriptServiceAttribute.cs
- ProvideValueServiceProvider.cs
- PropertyEmitter.cs
- EncoderFallback.cs
- TextDecoration.cs
- Stream.cs
- SspiWrapper.cs
- FontUnit.cs
- PolicyDesigner.cs
- SoapInteropTypes.cs
- AsyncStreamReader.cs
- AmbientValueAttribute.cs
- RuntimeResourceSet.cs
- XPathPatternParser.cs
- KeysConverter.cs
- EventBuilder.cs
- ECDsa.cs
- UserControlParser.cs
- CellParagraph.cs
- ServiceMetadataExtension.cs
- IApplicationTrustManager.cs
- ProcessModelInfo.cs