Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- HttpHandlerAction.cs
- SynchronizedInputAdaptor.cs
- NetworkInformationPermission.cs
- TextFormatter.cs
- SimpleRecyclingCache.cs
- _AutoWebProxyScriptHelper.cs
- Figure.cs
- FixedDocument.cs
- DocumentReferenceCollection.cs
- AsymmetricSignatureDeformatter.cs
- SystemIPAddressInformation.cs
- PlaceHolder.cs
- XmlSerializerAssemblyAttribute.cs
- ProfileSettings.cs
- EventsTab.cs
- FeatureSupport.cs
- RadialGradientBrush.cs
- DynamicQueryableWrapper.cs
- ButtonBaseAutomationPeer.cs
- TabControlEvent.cs
- Transform3DCollection.cs
- XamlTreeBuilderBamlRecordWriter.cs
- fixedPageContentExtractor.cs
- HttpCookieCollection.cs
- StringValueSerializer.cs
- LogLogRecord.cs
- HttpFileCollectionBase.cs
- ResourcePermissionBase.cs
- TableProvider.cs
- TextEffect.cs
- DataGridAddNewRow.cs
- Fonts.cs
- ProgressChangedEventArgs.cs
- FormattedText.cs
- EmbeddedMailObjectCollectionEditor.cs
- TypeSystem.cs
- WebResourceAttribute.cs
- ValueOfAction.cs
- WebPartChrome.cs
- ApplicationSecurityManager.cs
- DbMetaDataColumnNames.cs
- SponsorHelper.cs
- GifBitmapDecoder.cs
- PrinterResolution.cs
- Message.cs
- CodeObject.cs
- DeviceOverridableAttribute.cs
- PeerObject.cs
- DesignerTransaction.cs
- TypeConverterHelper.cs
- HttpWrapper.cs
- AdapterDictionary.cs
- HttpServerUtilityWrapper.cs
- ChildDocumentBlock.cs
- ToolStripMenuItem.cs
- ViewgenGatekeeper.cs
- XPathAxisIterator.cs
- DataGridViewCellCollection.cs
- SortKey.cs
- HtmlInputRadioButton.cs
- DataServiceContext.cs
- DbModificationCommandTree.cs
- ManipulationBoundaryFeedbackEventArgs.cs
- MsmqOutputChannel.cs
- _AuthenticationState.cs
- BaseDataListDesigner.cs
- AlignmentYValidation.cs
- StructuredType.cs
- NameValueCache.cs
- FormsAuthenticationCredentials.cs
- formatter.cs
- Claim.cs
- ListDictionaryInternal.cs
- CharEntityEncoderFallback.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- PolyBezierSegment.cs
- TypeConverterMarkupExtension.cs
- UnmanagedMemoryAccessor.cs
- CodeDomConfigurationHandler.cs
- FontInfo.cs
- ExtendedProtectionPolicy.cs
- ListItemDetailViewAttribute.cs
- LowerCaseStringConverter.cs
- FixedTextView.cs
- XmlSchemaComplexContentExtension.cs
- XmlWellformedWriter.cs
- UserControlDocumentDesigner.cs
- TypeUtil.cs
- ReadOnlyKeyedCollection.cs
- EdmComplexTypeAttribute.cs
- QuaternionKeyFrameCollection.cs
- TimeStampChecker.cs
- CommonRemoteMemoryBlock.cs
- StrongNameKeyPair.cs
- Semaphore.cs
- PersonalizationEntry.cs
- basecomparevalidator.cs
- DependencyProperty.cs
- QilReplaceVisitor.cs
- Baml2006ReaderSettings.cs