Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Transactions.cs
- ScrollEventArgs.cs
- AnnotationComponentChooser.cs
- ToolStripPanelRow.cs
- MethodRental.cs
- HandlerFactoryCache.cs
- TextTreeUndo.cs
- ApplicationProxyInternal.cs
- AbstractExpressions.cs
- PerformanceCounterNameAttribute.cs
- CallTemplateAction.cs
- hresults.cs
- ToolStripActionList.cs
- WebPartVerbsEventArgs.cs
- TypeSource.cs
- ExecutionContext.cs
- ImageDrawing.cs
- XmlBinaryWriter.cs
- OdbcHandle.cs
- RadioButton.cs
- WpfGeneratedKnownTypes.cs
- StylusDevice.cs
- InfoCardAsymmetricCrypto.cs
- OutputCacheSection.cs
- dsa.cs
- JapaneseLunisolarCalendar.cs
- AssociationTypeEmitter.cs
- PersonalizationState.cs
- DesignTimeHTMLTextWriter.cs
- CLSCompliantAttribute.cs
- BoundPropertyEntry.cs
- ImagingCache.cs
- CodeDelegateInvokeExpression.cs
- SignedXml.cs
- TabControl.cs
- FlatButtonAppearance.cs
- PrivateFontCollection.cs
- XsltInput.cs
- CookieProtection.cs
- AppDomainProtocolHandler.cs
- GiveFeedbackEvent.cs
- Block.cs
- SqlNotificationRequest.cs
- ToolStripContainer.cs
- WaitHandle.cs
- Attachment.cs
- SqlBooleanizer.cs
- WriteableOnDemandStream.cs
- AnonymousIdentificationModule.cs
- ItemType.cs
- ChangeNode.cs
- FixedSOMSemanticBox.cs
- RegisteredScript.cs
- SplitterPanel.cs
- DecoderFallbackWithFailureFlag.cs
- Hashtable.cs
- DefaultObjectMappingItemCollection.cs
- XPathNodeInfoAtom.cs
- IPEndPoint.cs
- TextBoxView.cs
- IntegrationExceptionEventArgs.cs
- DetailsViewPageEventArgs.cs
- mda.cs
- oledbmetadatacolumnnames.cs
- Exceptions.cs
- ReflectPropertyDescriptor.cs
- Activity.cs
- TreeNodeBindingCollection.cs
- XmlArrayItemAttributes.cs
- WorkflowApplicationCompletedEventArgs.cs
- DataListItem.cs
- BooleanAnimationBase.cs
- DependentTransaction.cs
- XmlCodeExporter.cs
- EncryptedXml.cs
- SecurityKeyIdentifierClause.cs
- FileIOPermission.cs
- WsdlWriter.cs
- ByteArrayHelperWithString.cs
- StagingAreaInputItem.cs
- CollectionsUtil.cs
- ProxyFragment.cs
- ipaddressinformationcollection.cs
- ObjectQueryState.cs
- DBNull.cs
- TemplateFactory.cs
- ListViewUpdatedEventArgs.cs
- EntityWithKeyStrategy.cs
- WriteStateInfoBase.cs
- StickyNoteHelper.cs
- RoutedEventConverter.cs
- PieceNameHelper.cs
- WebPartDisplayModeCollection.cs
- WindowsNonControl.cs
- FtpWebRequest.cs
- TraceUtils.cs
- OSFeature.cs
- ParserStack.cs
- SqlBuffer.cs
- RoleGroup.cs