Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Serializer / DependencyStoreSurrogate.cs / 1305376 / DependencyStoreSurrogate.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 DependencyStoreSurrogate internal sealed class DependencyStoreSurrogate : ISerializationSurrogate { internal DependencyStoreSurrogate() { } void ISerializationSurrogate.GetObjectData(object obj, SerializationInfo info, StreamingContext context) { IDictionarystore = obj as IDictionary ; if (store == null) throw new ArgumentException("obj"); ArrayList properties = new ArrayList(); ArrayList values = new ArrayList(); foreach (KeyValuePair kvp in store) { if (!kvp.Key.DefaultMetadata.IsNonSerialized) { if (kvp.Key.IsKnown) properties.Add(kvp.Key.KnownIndex); else properties.Add(kvp.Key); values.Add(kvp.Value); } } info.AddValue("keys", properties.ToArray()); info.AddValue("values", values.ToArray()); info.SetType(typeof(DependencyStoreRef)); } object ISerializationSurrogate.SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { return null; } #region DependencyStoreRef [Serializable] private sealed class DependencyStoreRef : IObjectReference, IDeserializationCallback { private IList keys = null; private IList values = null; [NonSerialized] private IDictionary store = null; Object IObjectReference.GetRealObject(StreamingContext context) { if (this.store == null) this.store = new Dictionary (); return this.store; } void IDeserializationCallback.OnDeserialization(Object sender) { if (this.store != null) { for (int index = 0; index < this.keys.Count; index++) { DependencyProperty dp = this.keys[index] as DependencyProperty; if (dp == null) dp = DependencyProperty.FromKnown((byte)this.keys[index]); this.store.Add(dp, this.values[index]); } } this.store = 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
- safelink.cs
- DecimalConstantAttribute.cs
- SessionEndingEventArgs.cs
- MatrixIndependentAnimationStorage.cs
- ButtonChrome.cs
- DBCommandBuilder.cs
- AnnotationResource.cs
- WindowsSolidBrush.cs
- PointCollection.cs
- DiscoveryMessageSequenceCD1.cs
- XmlSerializerObjectSerializer.cs
- DynamicRendererThreadManager.cs
- DelegatingConfigHost.cs
- ResponseStream.cs
- SpecialTypeDataContract.cs
- ConfigurationProperty.cs
- HashMembershipCondition.cs
- GenericTypeParameterBuilder.cs
- QueryGenerator.cs
- ADMembershipProvider.cs
- LazyTextWriterCreator.cs
- TraceHandlerErrorFormatter.cs
- Error.cs
- PhonemeEventArgs.cs
- ConsoleTraceListener.cs
- TransformerInfo.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- WebEventCodes.cs
- WebBrowserUriTypeConverter.cs
- SafeFileHandle.cs
- COM2PictureConverter.cs
- EntityDataSourceState.cs
- WebPartDisplayModeEventArgs.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- OverflowException.cs
- SrgsSemanticInterpretationTag.cs
- HttpCapabilitiesEvaluator.cs
- HiddenFieldDesigner.cs
- ColumnResult.cs
- ConsoleKeyInfo.cs
- InterleavedZipPartStream.cs
- SplitContainer.cs
- Style.cs
- CaseExpr.cs
- SystemIcmpV4Statistics.cs
- DataListItemEventArgs.cs
- ConfigViewGenerator.cs
- LineGeometry.cs
- ContentElementAutomationPeer.cs
- HTTPNotFoundHandler.cs
- IERequestCache.cs
- SqlDataSourceCommandEventArgs.cs
- ProfileSection.cs
- BaseDataList.cs
- TypeForwardedToAttribute.cs
- DataGridClipboardCellContent.cs
- LogRecordSequence.cs
- AccessDataSourceView.cs
- DefaultSection.cs
- ProjectionRewriter.cs
- ToggleButtonAutomationPeer.cs
- FormsAuthenticationUserCollection.cs
- MaterialGroup.cs
- BinHexDecoder.cs
- FrameworkElement.cs
- ProcessHostServerConfig.cs
- AgileSafeNativeMemoryHandle.cs
- formatter.cs
- Margins.cs
- DropSource.cs
- ElapsedEventArgs.cs
- TableLayoutSettingsTypeConverter.cs
- RootBrowserWindowProxy.cs
- ScaleTransform3D.cs
- InitializationEventAttribute.cs
- StylusOverProperty.cs
- LinqDataSourceValidationException.cs
- SetterBaseCollection.cs
- regiisutil.cs
- XmlHelper.cs
- MatrixUtil.cs
- FormsAuthenticationConfiguration.cs
- ArgumentException.cs
- ScriptResourceHandler.cs
- SqlLiftIndependentRowExpressions.cs
- keycontainerpermission.cs
- MailAddress.cs
- GenerateDerivedKeyRequest.cs
- SchemaTableOptionalColumn.cs
- Overlapped.cs
- SourceSwitch.cs
- _AuthenticationState.cs
- KeyValueSerializer.cs
- WindowsListBox.cs
- SuppressMessageAttribute.cs
- _ContextAwareResult.cs
- _LocalDataStore.cs
- FileUtil.cs
- DataGridViewTextBoxColumn.cs
- WindowsScroll.cs