Code:
/ FX-1434 / FX-1434 / 1.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
- GeneralTransform3DGroup.cs
- ModelEditingScope.cs
- ReferentialConstraint.cs
- TemplateControl.cs
- RestHandler.cs
- WebZone.cs
- SingleConverter.cs
- Function.cs
- ContractMethodParameterInfo.cs
- DashStyle.cs
- _HTTPDateParse.cs
- TreeNodeCollection.cs
- RTLAwareMessageBox.cs
- InvariantComparer.cs
- DisposableCollectionWrapper.cs
- ResourceWriter.cs
- XmlSchemaInclude.cs
- MediaPlayerState.cs
- ButtonStandardAdapter.cs
- MetadataItem.cs
- NeedSkipTokenVisitor.cs
- EndEvent.cs
- SQLInt32Storage.cs
- Utils.cs
- EditingMode.cs
- XmlNodeChangedEventArgs.cs
- QuaternionRotation3D.cs
- PageHandlerFactory.cs
- DropDownButton.cs
- LineServicesRun.cs
- ControlValuePropertyAttribute.cs
- WmlFormAdapter.cs
- QilExpression.cs
- UserValidatedEventArgs.cs
- AsymmetricAlgorithm.cs
- TypedTableBaseExtensions.cs
- MemoryFailPoint.cs
- HealthMonitoringSectionHelper.cs
- XPathDocumentIterator.cs
- ImageSourceConverter.cs
- DataGridViewTopRowAccessibleObject.cs
- RowsCopiedEventArgs.cs
- SeekStoryboard.cs
- MailAddress.cs
- QilIterator.cs
- X500Name.cs
- UpDownEvent.cs
- CommandEventArgs.cs
- XmlSchemaImport.cs
- altserialization.cs
- CodeExporter.cs
- EntityDataSourceSelectedEventArgs.cs
- HttpClientCertificate.cs
- SendingRequestEventArgs.cs
- NumericUpDownAcceleration.cs
- counter.cs
- StringFunctions.cs
- ConfigXmlReader.cs
- nulltextcontainer.cs
- GeneratedCodeAttribute.cs
- MULTI_QI.cs
- FilteredAttributeCollection.cs
- SecondaryIndex.cs
- figurelengthconverter.cs
- PropertyMetadata.cs
- COM2Enum.cs
- SeekStoryboard.cs
- RemoteWebConfigurationHostStream.cs
- ObjectReaderCompiler.cs
- Helper.cs
- ElapsedEventArgs.cs
- GridViewDeletedEventArgs.cs
- SemanticResultValue.cs
- DecimalMinMaxAggregationOperator.cs
- ProtocolsConfigurationEntry.cs
- Missing.cs
- AllMembershipCondition.cs
- HttpModuleCollection.cs
- SQLInt32.cs
- Script.cs
- SerializableAttribute.cs
- BrowserDefinitionCollection.cs
- ActivityExecutionContextCollection.cs
- SystemInformation.cs
- DocumentPageViewAutomationPeer.cs
- SolidBrush.cs
- IPPacketInformation.cs
- BuildResult.cs
- DataGridViewLayoutData.cs
- FunctionNode.cs
- ClientRuntimeConfig.cs
- Calendar.cs
- TypeValidationEventArgs.cs
- DisplayInformation.cs
- VirtualizingPanel.cs
- Int16.cs
- Win32Exception.cs
- CodeObject.cs
- Range.cs
- BamlVersionHeader.cs