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
- MbpInfo.cs
- ControlFilterExpression.cs
- CookieProtection.cs
- DataSourceSelectArguments.cs
- Listen.cs
- ClientSideProviderDescription.cs
- CommonRemoteMemoryBlock.cs
- DbCommandTree.cs
- AlternationConverter.cs
- ClientCredentials.cs
- DateBoldEvent.cs
- ProcessProtocolHandler.cs
- StringUtil.cs
- DisplayInformation.cs
- ContractAdapter.cs
- CodeGen.cs
- UserMapPath.cs
- ClientSideProviderDescription.cs
- Debug.cs
- ConfigXmlWhitespace.cs
- WebPartMovingEventArgs.cs
- SmtpLoginAuthenticationModule.cs
- StylusPointDescription.cs
- ToolStripDropDownItemDesigner.cs
- AttributeQuery.cs
- FilterQueryOptionExpression.cs
- X509Chain.cs
- CodeParameterDeclarationExpression.cs
- CollectionsUtil.cs
- ConnectionPoint.cs
- DateTimeOffsetStorage.cs
- AsyncInvokeContext.cs
- Error.cs
- BigInt.cs
- MobileControlsSectionHelper.cs
- IdentifierCollection.cs
- ViewKeyConstraint.cs
- SemaphoreSecurity.cs
- TextElementAutomationPeer.cs
- PlainXmlSerializer.cs
- CryptographicAttribute.cs
- Debug.cs
- NativeCppClassAttribute.cs
- TableRowCollection.cs
- TimelineClockCollection.cs
- DateTimeSerializationSection.cs
- HorizontalAlignConverter.cs
- CodeDomSerializerException.cs
- CalloutQueueItem.cs
- HtmlProps.cs
- StrongNameKeyPair.cs
- DataObjectCopyingEventArgs.cs
- DependencyObject.cs
- UmAlQuraCalendar.cs
- CollectionViewGroupInternal.cs
- FunctionMappingTranslator.cs
- BaseContextMenu.cs
- MetaTableHelper.cs
- ServicePointManager.cs
- _LocalDataStoreMgr.cs
- CollectionViewProxy.cs
- FilterQuery.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- ServiceModelStringsVersion1.cs
- xsdvalidator.cs
- DiagnosticTraceSource.cs
- RelationshipManager.cs
- Options.cs
- FileChangesMonitor.cs
- XmlIncludeAttribute.cs
- StringInfo.cs
- PagedControl.cs
- Single.cs
- TrackingConditionCollection.cs
- EndpointDispatcher.cs
- ElementAtQueryOperator.cs
- BuildProviderInstallComponent.cs
- PlainXmlWriter.cs
- AuthenticationService.cs
- SendKeys.cs
- InvalidateEvent.cs
- ObjectHandle.cs
- ComUdtElementCollection.cs
- SQLChars.cs
- SettingsProviderCollection.cs
- ConnectionStringEditor.cs
- SelectionPattern.cs
- XmlWriterTraceListener.cs
- PropertyMap.cs
- WorkflowPrinting.cs
- UrlPropertyAttribute.cs
- ScrollPatternIdentifiers.cs
- WindowsSecurityToken.cs
- PageAsyncTaskManager.cs
- XmlHierarchyData.cs
- OleDbEnumerator.cs
- ProfileSection.cs
- SchemaInfo.cs
- DomainUpDown.cs
- HandledMouseEvent.cs