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
- ObjectTag.cs
- TrackingProfile.cs
- ReadOnlyObservableCollection.cs
- ChtmlTextWriter.cs
- PropertyValueUIItem.cs
- ProtectedConfiguration.cs
- ObjectItemConventionAssemblyLoader.cs
- AttributeCollection.cs
- Compiler.cs
- ConnectionManagementElement.cs
- TypeDelegator.cs
- Properties.cs
- CngKeyCreationParameters.cs
- ContentPresenter.cs
- GridViewColumnHeader.cs
- EmptyControlCollection.cs
- TextTreeUndoUnit.cs
- SafeTimerHandle.cs
- ExtenderControl.cs
- WebPartMenu.cs
- ObjectDataSource.cs
- MemberProjectionIndex.cs
- CharacterHit.cs
- Point3DCollection.cs
- WindowsGraphicsWrapper.cs
- AsymmetricAlgorithm.cs
- FixedPageAutomationPeer.cs
- DockPattern.cs
- RpcAsyncResult.cs
- XmlCharCheckingWriter.cs
- ping.cs
- CellParaClient.cs
- CollectionsUtil.cs
- DesignerWithHeader.cs
- MissingManifestResourceException.cs
- PolyLineSegment.cs
- FamilyCollection.cs
- SizeF.cs
- SeekableMessageNavigator.cs
- IdentifierService.cs
- EntityDataSourceStatementEditorForm.cs
- RadialGradientBrush.cs
- MessageLogger.cs
- CompositeFontInfo.cs
- RSACryptoServiceProvider.cs
- DbProviderSpecificTypePropertyAttribute.cs
- ExpressionLexer.cs
- DependencySource.cs
- GenericUriParser.cs
- PreviewPageInfo.cs
- PointLight.cs
- ResourceDescriptionAttribute.cs
- Page.cs
- BitmapPalette.cs
- Tokenizer.cs
- _ProxyRegBlob.cs
- MissingMemberException.cs
- Msec.cs
- ScalarOps.cs
- InstancePersistence.cs
- UserUseLicenseDictionaryLoader.cs
- RectConverter.cs
- Task.cs
- Policy.cs
- Privilege.cs
- UInt64.cs
- ReadOnlyHierarchicalDataSourceView.cs
- MsmqProcessProtocolHandler.cs
- VScrollBar.cs
- SetIndexBinder.cs
- TargetControlTypeCache.cs
- XmlLanguage.cs
- FixedSOMTable.cs
- FileDialog_Vista.cs
- FileDialog.cs
- FlowDocumentView.cs
- CodeThrowExceptionStatement.cs
- ResourceDictionaryCollection.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- CommandBindingCollection.cs
- SocketException.cs
- InvokeHandlers.cs
- ResourceReader.cs
- MethodImplAttribute.cs
- DefaultParameterValueAttribute.cs
- TemplateNodeContextMenu.cs
- TextPointer.cs
- HtmlTableRow.cs
- CreateUserErrorEventArgs.cs
- CodePageUtils.cs
- DbExpressionRules.cs
- ListBoxItemWrapperAutomationPeer.cs
- KeyedHashAlgorithm.cs
- ToolStripTextBox.cs
- ScrollChrome.cs
- NotFiniteNumberException.cs
- AppDomain.cs
- TcpTransportManager.cs
- ClientScriptManager.cs
- TreeView.cs