Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Serializer / QueueSurrogate.cs / 1305376 / QueueSurrogate.cs
namespace System.Workflow.ComponentModel.Serialization { using System; using System.Xml; using System.Runtime.Serialization; using System.Reflection; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Collections; using System.Collections.Generic; #region QueueSurrogate internal sealed class QueueSurrogate : ISerializationSurrogate { internal QueueSurrogate() { } void ISerializationSurrogate.GetObjectData(object obj, SerializationInfo info, StreamingContext context) { object[] items = ((Queue)obj).ToArray(); if (items.Length == 1) info.AddValue("item", items[0]); else info.AddValue("items", items); info.SetType(typeof(QRef)); } object ISerializationSurrogate.SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { return null; } #region QRef [Serializable] private sealed class QRef : IObjectReference, IDeserializationCallback { [OptionalField] private IList items = null; [OptionalField] private object item = null; [NonSerialized] private Queue queue = null; Object IObjectReference.GetRealObject(StreamingContext context) { if (this.queue == null) { this.queue = new Queue(); } return this.queue; } void IDeserializationCallback.OnDeserialization(Object sender) { if (this.queue != null) { if (this.items != null) { for (int n = 0; n < this.items.Count; n++) this.queue.Enqueue(items[n]); } else { this.queue.Enqueue(this.item); } this.queue = null; } } } #endregion } #endregion } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Workflow.ComponentModel.Serialization { using System; using System.Xml; using System.Runtime.Serialization; using System.Reflection; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Collections; using System.Collections.Generic; #region QueueSurrogate internal sealed class QueueSurrogate : ISerializationSurrogate { internal QueueSurrogate() { } void ISerializationSurrogate.GetObjectData(object obj, SerializationInfo info, StreamingContext context) { object[] items = ((Queue)obj).ToArray(); if (items.Length == 1) info.AddValue("item", items[0]); else info.AddValue("items", items); info.SetType(typeof(QRef)); } object ISerializationSurrogate.SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { return null; } #region QRef [Serializable] private sealed class QRef : IObjectReference, IDeserializationCallback { [OptionalField] private IList items = null; [OptionalField] private object item = null; [NonSerialized] private Queue queue = null; Object IObjectReference.GetRealObject(StreamingContext context) { if (this.queue == null) { this.queue = new Queue(); } return this.queue; } void IDeserializationCallback.OnDeserialization(Object sender) { if (this.queue != null) { if (this.items != null) { for (int n = 0; n < this.items.Count; n++) this.queue.Enqueue(items[n]); } else { this.queue.Enqueue(this.item); } this.queue = null; } } } #endregion } #endregion } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpRuntime.cs
- ObjectViewFactory.cs
- PrintPreviewControl.cs
- ImageSource.cs
- StylusShape.cs
- StyleXamlTreeBuilder.cs
- PlaceHolder.cs
- DataGridViewElement.cs
- ControlPager.cs
- PersonalizationState.cs
- PropertyValueUIItem.cs
- ObjectDataSourceMethodEventArgs.cs
- StatusBarPanelClickEvent.cs
- NonClientArea.cs
- ItemContainerProviderWrapper.cs
- AvtEvent.cs
- Grid.cs
- ViewManagerAttribute.cs
- FormConverter.cs
- StateItem.cs
- BaseCAMarshaler.cs
- UnmanagedMemoryStream.cs
- HtmlWindow.cs
- NonSerializedAttribute.cs
- BaseTemplateParser.cs
- DispatcherExceptionEventArgs.cs
- SafeRightsManagementHandle.cs
- TextTreeExtractElementUndoUnit.cs
- IntSecurity.cs
- Bits.cs
- ProtocolsConfigurationHandler.cs
- FontWeights.cs
- DataGridRowAutomationPeer.cs
- DataBindingHandlerAttribute.cs
- DiscardableAttribute.cs
- ShaderEffect.cs
- webbrowsersite.cs
- ComboBoxItem.cs
- MetadataFile.cs
- OletxTransactionManager.cs
- ReadWriteObjectLock.cs
- DBBindings.cs
- PingOptions.cs
- UpdateCompiler.cs
- Help.cs
- TrustLevel.cs
- HttpProxyCredentialType.cs
- cookiecollection.cs
- UnknownBitmapDecoder.cs
- ActiveXContainer.cs
- MdiWindowListItemConverter.cs
- CatalogZoneBase.cs
- DrawingCollection.cs
- ResXResourceReader.cs
- TemplateControl.cs
- PlatformNotSupportedException.cs
- TriggerAction.cs
- UnsafeNativeMethods.cs
- HttpWebRequestElement.cs
- ProxyHelper.cs
- SymbolMethod.cs
- AttachInfo.cs
- XPathNavigatorKeyComparer.cs
- ReferenceSchema.cs
- SHA384.cs
- _KerberosClient.cs
- RawStylusSystemGestureInputReport.cs
- sortedlist.cs
- AsyncResult.cs
- UpdateTranslator.cs
- SqlDependencyUtils.cs
- WebEventTraceProvider.cs
- RightsManagementInformation.cs
- TextDecoration.cs
- UrlPropertyAttribute.cs
- TabItemWrapperAutomationPeer.cs
- HostSecurityManager.cs
- Schema.cs
- XmlImplementation.cs
- RecognitionEventArgs.cs
- securitycriticaldataClass.cs
- ADMembershipUser.cs
- AppDomainCompilerProxy.cs
- FixedStringLookup.cs
- MouseGestureValueSerializer.cs
- PointAnimationUsingPath.cs
- HttpProtocolImporter.cs
- Mutex.cs
- SingleStorage.cs
- RootBrowserWindow.cs
- ThreadPool.cs
- ColorKeyFrameCollection.cs
- SizeLimitedCache.cs
- ReachSerializationCacheItems.cs
- SchemaAttDef.cs
- HashCodeCombiner.cs
- RenamedEventArgs.cs
- ListViewItemCollectionEditor.cs
- CacheManager.cs
- XmlQualifiedNameTest.cs