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
- Registry.cs
- BitmapEditor.cs
- OperationInvokerTrace.cs
- JsonFormatMapping.cs
- StringCollection.cs
- SamlAssertion.cs
- ScrollBarAutomationPeer.cs
- TcpTransportManager.cs
- ExceptionValidationRule.cs
- ComponentCollection.cs
- DispatcherTimer.cs
- WorkflowMarkupSerializationManager.cs
- AutoResizedEvent.cs
- XmlWriterTraceListener.cs
- ExternalFile.cs
- FormatterServicesNoSerializableCheck.cs
- SerializationSectionGroup.cs
- SystemTcpConnection.cs
- MetaModel.cs
- HiddenFieldPageStatePersister.cs
- EventTrigger.cs
- SystemIPv6InterfaceProperties.cs
- SqlBulkCopyColumnMapping.cs
- SqlDataRecord.cs
- IArgumentProvider.cs
- WebPartAuthorizationEventArgs.cs
- SecurityResources.cs
- ACL.cs
- TemplateInstanceAttribute.cs
- ProxyAttribute.cs
- BitStack.cs
- Utilities.cs
- _ShellExpression.cs
- NextPreviousPagerField.cs
- NameValueFileSectionHandler.cs
- _RequestLifetimeSetter.cs
- DataGridViewCellPaintingEventArgs.cs
- NativeMethodsCLR.cs
- DataGridViewCellLinkedList.cs
- CultureInfo.cs
- WmlPanelAdapter.cs
- Compiler.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- MailWebEventProvider.cs
- TabControlEvent.cs
- CodeArgumentReferenceExpression.cs
- OracleBinary.cs
- TextContainerChangedEventArgs.cs
- AppDomainUnloadedException.cs
- AssemblyAttributes.cs
- Transform3DCollection.cs
- FormViewDesigner.cs
- CasesDictionary.cs
- NonVisualControlAttribute.cs
- SqlDuplicator.cs
- EditorPartDesigner.cs
- MenuItemBinding.cs
- StreamReader.cs
- FontDialog.cs
- DataGridView.cs
- ExpandCollapseProviderWrapper.cs
- ButtonBaseAdapter.cs
- UTF7Encoding.cs
- ConfigXmlElement.cs
- LinqExpressionNormalizer.cs
- InvalidOperationException.cs
- RuntimeResourceSet.cs
- LocalizedNameDescriptionPair.cs
- XmlProcessingInstruction.cs
- GuidConverter.cs
- FormViewInsertedEventArgs.cs
- DtrList.cs
- CodeExporter.cs
- HtmlHistory.cs
- ModuleConfigurationInfo.cs
- ObjectQueryState.cs
- basecomparevalidator.cs
- ListViewInsertEventArgs.cs
- TraceSection.cs
- ReturnEventArgs.cs
- EngineSite.cs
- CallbackDebugBehavior.cs
- BoundingRectTracker.cs
- CultureNotFoundException.cs
- HMACMD5.cs
- NamedElement.cs
- NamedPipeConnectionPoolSettingsElement.cs
- TextEffectResolver.cs
- X509SubjectKeyIdentifierClause.cs
- documentsequencetextcontainer.cs
- TextEffectCollection.cs
- ListBoxItem.cs
- RtfToXamlReader.cs
- DbDeleteCommandTree.cs
- WorkflowElementDialogWindow.xaml.cs
- AssemblyBuilder.cs
- TdsValueSetter.cs
- SamlAction.cs
- EventLogPermissionEntry.cs
- SharedDp.cs