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
- cookiecontainer.cs
- httpserverutility.cs
- EditorServiceContext.cs
- StickyNote.cs
- MatrixConverter.cs
- MaxMessageSizeStream.cs
- LinkLabelLinkClickedEvent.cs
- DelegateArgumentReference.cs
- Trigger.cs
- X509IssuerSerialKeyIdentifierClause.cs
- DataBoundControlDesigner.cs
- SourceInterpreter.cs
- TextCompositionEventArgs.cs
- DataGridTextBoxColumn.cs
- DSASignatureDeformatter.cs
- RuntimeVariablesExpression.cs
- FormViewActionList.cs
- FontClient.cs
- OleStrCAMarshaler.cs
- MenuBase.cs
- SequenceRangeCollection.cs
- SharedConnectionInfo.cs
- ErrorRuntimeConfig.cs
- AffineTransform3D.cs
- DataObjectFieldAttribute.cs
- LoginAutoFormat.cs
- HierarchicalDataSourceControl.cs
- Tuple.cs
- VideoDrawing.cs
- DATA_BLOB.cs
- RtfToXamlReader.cs
- _SingleItemRequestCache.cs
- FixedSOMLineCollection.cs
- Keywords.cs
- TypeReference.cs
- SamlAdvice.cs
- Positioning.cs
- FilterQuery.cs
- Message.cs
- RegistrySecurity.cs
- Rotation3D.cs
- QEncodedStream.cs
- TransformProviderWrapper.cs
- SetterBaseCollection.cs
- CollectionChangedEventManager.cs
- Tag.cs
- VisualTransition.cs
- RadioButton.cs
- StylusPointProperty.cs
- SplashScreenNativeMethods.cs
- HttpProfileGroupBase.cs
- TreeViewCancelEvent.cs
- WebPartEditorOkVerb.cs
- SqlConnectionPoolGroupProviderInfo.cs
- Zone.cs
- CalendarItem.cs
- PackageProperties.cs
- ComEventsHelper.cs
- DeploymentSectionCache.cs
- DelegatedStream.cs
- MemberInfoSerializationHolder.cs
- XmlQuerySequence.cs
- WebBrowserHelper.cs
- ValidatorCollection.cs
- TableColumnCollectionInternal.cs
- DataGridViewTopLeftHeaderCell.cs
- DataViewManager.cs
- _NestedSingleAsyncResult.cs
- TimeStampChecker.cs
- PropertyToken.cs
- Point3DCollection.cs
- InputReferenceExpression.cs
- XamlReaderHelper.cs
- SafeThemeHandle.cs
- UserPreference.cs
- MatrixAnimationUsingKeyFrames.cs
- configsystem.cs
- XmlIlVisitor.cs
- RepeatBehaviorConverter.cs
- DataViewSettingCollection.cs
- XMLDiffLoader.cs
- ICspAsymmetricAlgorithm.cs
- DayRenderEvent.cs
- Filter.cs
- SignedXmlDebugLog.cs
- SwitchAttribute.cs
- PreloadedPackages.cs
- _AutoWebProxyScriptWrapper.cs
- TableLayout.cs
- GenerateScriptTypeAttribute.cs
- WebPartMenuStyle.cs
- Int32CollectionValueSerializer.cs
- ContextMenuStrip.cs
- NullRuntimeConfig.cs
- WebPartsSection.cs
- ClientEventManager.cs
- AuthenticationService.cs
- TrackBar.cs
- PeerChannelFactory.cs
- ComponentDispatcher.cs