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
- BitmapMetadataEnumerator.cs
- SingleAnimationBase.cs
- ConditionalAttribute.cs
- WorkflowTerminatedException.cs
- SystemColorTracker.cs
- XMLUtil.cs
- RegistryKey.cs
- XmlSiteMapProvider.cs
- XmlDataSource.cs
- RepeatEnumerable.cs
- AxHost.cs
- TreeViewEvent.cs
- UriTemplateDispatchFormatter.cs
- DSACryptoServiceProvider.cs
- TransformCryptoHandle.cs
- UiaCoreApi.cs
- SqlConnection.cs
- AutomationElementCollection.cs
- TableRow.cs
- CheckedPointers.cs
- PlaceHolder.cs
- TextBlockAutomationPeer.cs
- HandleDictionary.cs
- WindowsListBox.cs
- TemplateControlCodeDomTreeGenerator.cs
- FullTextBreakpoint.cs
- XmlHierarchicalEnumerable.cs
- ProcessManager.cs
- XmlExtensionFunction.cs
- CompositeActivityTypeDescriptorProvider.cs
- DesignerForm.cs
- EventLogPermissionHolder.cs
- rsa.cs
- Part.cs
- UserPreferenceChangedEventArgs.cs
- MouseGestureValueSerializer.cs
- SchemaNamespaceManager.cs
- TypedReference.cs
- CustomWebEventKey.cs
- OracleDataAdapter.cs
- ReadOnlyActivityGlyph.cs
- ListItemCollection.cs
- MappedMetaModel.cs
- ConfigurationException.cs
- Parameter.cs
- ProxyWebPartManager.cs
- ContractListAdapter.cs
- XmlSerializerAssemblyAttribute.cs
- SelectedDatesCollection.cs
- ToolStripContainer.cs
- HMAC.cs
- SecUtil.cs
- VisualStyleRenderer.cs
- ParseChildrenAsPropertiesAttribute.cs
- Privilege.cs
- BevelBitmapEffect.cs
- GeneralTransform3DTo2DTo3D.cs
- SolidColorBrush.cs
- ItemCheckEvent.cs
- PenContexts.cs
- EnvelopedPkcs7.cs
- CreateParams.cs
- ScriptResourceAttribute.cs
- ErrorStyle.cs
- XmlTextReaderImplHelpers.cs
- EventRoute.cs
- ImageListStreamer.cs
- SamlAttributeStatement.cs
- TreeNodeStyleCollection.cs
- DataKey.cs
- SessionStateContainer.cs
- Bitmap.cs
- XmlElementList.cs
- StatusBarDesigner.cs
- MessageQueueConverter.cs
- PackWebRequestFactory.cs
- Grid.cs
- TraceUtility.cs
- DataServiceRequestOfT.cs
- EditorAttribute.cs
- SqlWebEventProvider.cs
- BindingElementExtensionElement.cs
- DataGridViewUtilities.cs
- _ContextAwareResult.cs
- DesignerCommandAdapter.cs
- UInt64.cs
- WebPartCatalogCloseVerb.cs
- WorkflowPrinting.cs
- FieldToken.cs
- DataGridViewColumnEventArgs.cs
- ExpressionDumper.cs
- XPathAxisIterator.cs
- MouseEvent.cs
- TreeNodeBindingCollection.cs
- CompoundFileIOPermission.cs
- path.cs
- XsdDateTime.cs
- DataGridCommandEventArgs.cs
- PassportAuthenticationEventArgs.cs
- MemberRelationshipService.cs