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
- TraceHwndHost.cs
- GridViewSelectEventArgs.cs
- SqlErrorCollection.cs
- FloatSumAggregationOperator.cs
- DataGridViewRowHeaderCell.cs
- TypeDependencyAttribute.cs
- SimpleLine.cs
- KeyValuePairs.cs
- Memoizer.cs
- SHA256Managed.cs
- PropertyPath.cs
- OptionalColumn.cs
- InstanceView.cs
- XamlPathDataSerializer.cs
- PageStatePersister.cs
- Int32RectConverter.cs
- ViewSimplifier.cs
- StringToken.cs
- DataPagerFieldCommandEventArgs.cs
- OutputScopeManager.cs
- _NtlmClient.cs
- SemanticKeyElement.cs
- ModuleConfigurationInfo.cs
- MaskDescriptors.cs
- Vector3DKeyFrameCollection.cs
- CancelEventArgs.cs
- SweepDirectionValidation.cs
- PrePostDescendentsWalker.cs
- ItemCheckEvent.cs
- SocketPermission.cs
- SimpleType.cs
- BulletedList.cs
- QilReference.cs
- BitmapSizeOptions.cs
- DataRelationPropertyDescriptor.cs
- UnsafeNativeMethods.cs
- RichTextBox.cs
- NonValidatingSecurityTokenAuthenticator.cs
- ScrollBarRenderer.cs
- TargetException.cs
- IteratorFilter.cs
- Filter.cs
- ParameterBuilder.cs
- CompiledRegexRunner.cs
- AssemblyBuilderData.cs
- TransformerInfo.cs
- XPathExpr.cs
- SqlGenericUtil.cs
- ZipFileInfo.cs
- UserMapPath.cs
- AuthenticationManager.cs
- DiagnosticTrace.cs
- FrameworkElement.cs
- ToolStripSplitStackLayout.cs
- SqlCommand.cs
- DocumentPageViewAutomationPeer.cs
- MustUnderstandBehavior.cs
- StylusPointPropertyInfo.cs
- ToolStripItemDesigner.cs
- ZipIOCentralDirectoryFileHeader.cs
- StandardOleMarshalObject.cs
- URLString.cs
- SoapMessage.cs
- Native.cs
- SortQuery.cs
- SystemInfo.cs
- EndPoint.cs
- Directory.cs
- MachineKeySection.cs
- DependencyPropertyKey.cs
- DetailsViewInsertEventArgs.cs
- MemberInfoSerializationHolder.cs
- TransactionManager.cs
- ResourceSet.cs
- TemplateXamlParser.cs
- XmlTextReaderImpl.cs
- GroupItem.cs
- relpropertyhelper.cs
- FixedSOMTableCell.cs
- FileResponseElement.cs
- Sequence.cs
- FunctionGenerator.cs
- PrintController.cs
- URLIdentityPermission.cs
- _NetRes.cs
- ListViewItem.cs
- SqlStream.cs
- SerializationIncompleteException.cs
- WCFServiceClientProxyGenerator.cs
- BindingOperations.cs
- Line.cs
- TransactionProtocolConverter.cs
- MethodRental.cs
- WindowsTab.cs
- MessageBox.cs
- ActivityBuilderHelper.cs
- NamespaceCollection.cs
- FileLogRecordEnumerator.cs
- BitmapCodecInfoInternal.cs
- FontDriver.cs