Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- UniqueIdentifierService.cs
- StylusPoint.cs
- MarkedHighlightComponent.cs
- HttpSysSettings.cs
- SafeFileMapViewHandle.cs
- CounterSetInstance.cs
- X509CertificateInitiatorServiceCredential.cs
- TypographyProperties.cs
- TreeViewAutomationPeer.cs
- PageThemeParser.cs
- SByte.cs
- MTConfigUtil.cs
- GenericEnumConverter.cs
- ObjectDataSourceSelectingEventArgs.cs
- DataSourceExpressionCollection.cs
- DiscreteKeyFrames.cs
- StylusPoint.cs
- DataGridViewAddColumnDialog.cs
- TextMarkerSource.cs
- OleCmdHelper.cs
- ItemCheckedEvent.cs
- HttpModulesSection.cs
- CheckBoxList.cs
- RevocationPoint.cs
- InternalPolicyElement.cs
- ValueChangedEventManager.cs
- ListViewItem.cs
- UpdateCommand.cs
- EventSourceCreationData.cs
- MD5.cs
- PermissionSetEnumerator.cs
- RegistrationServices.cs
- TextModifier.cs
- XPathDocument.cs
- EpmTargetTree.cs
- GridItemPattern.cs
- RegexInterpreter.cs
- DiagnosticEventProvider.cs
- DeviceSpecific.cs
- DbParameterHelper.cs
- SoapAttributeOverrides.cs
- TaskFormBase.cs
- OdbcConnection.cs
- peernodestatemanager.cs
- DashStyle.cs
- EventLogPermissionEntry.cs
- SectionXmlInfo.cs
- PrivilegeNotHeldException.cs
- HttpServerUtilityWrapper.cs
- FolderBrowserDialogDesigner.cs
- NotFiniteNumberException.cs
- DetailsViewUpdatedEventArgs.cs
- CustomGrammar.cs
- NonParentingControl.cs
- PKCS1MaskGenerationMethod.cs
- Panel.cs
- BulletedListEventArgs.cs
- SessionPageStatePersister.cs
- TriState.cs
- LoginName.cs
- HttpPostLocalhostServerProtocol.cs
- Encoder.cs
- XmlWriterTraceListener.cs
- DataKeyArray.cs
- DataGridViewRowsAddedEventArgs.cs
- RequestDescription.cs
- Clipboard.cs
- streamingZipPartStream.cs
- TouchFrameEventArgs.cs
- GraphicsPath.cs
- DiscriminatorMap.cs
- ToolStripSystemRenderer.cs
- TreeNode.cs
- ArrayMergeHelper.cs
- SqlDataSourceCache.cs
- SqlTriggerContext.cs
- ControlBuilder.cs
- GridViewDeletedEventArgs.cs
- Regex.cs
- HtmlInputHidden.cs
- LoginCancelEventArgs.cs
- CommandBinding.cs
- future.cs
- RepeatBehaviorConverter.cs
- XmlQualifiedName.cs
- PngBitmapEncoder.cs
- Mutex.cs
- NavigatorOutput.cs
- StrokeRenderer.cs
- DependencyProperty.cs
- InfoCardProofToken.cs
- XmlTextReader.cs
- COM2AboutBoxPropertyDescriptor.cs
- LicenseException.cs
- UrlRoutingModule.cs
- NonVisualControlAttribute.cs
- CustomAttributeFormatException.cs
- ElementFactory.cs
- PageClientProxyGenerator.cs
- AddInToken.cs