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
- PartialToken.cs
- HostSecurityManager.cs
- DataDesignUtil.cs
- PackageStore.cs
- ObjectSecurityT.cs
- AppDomain.cs
- DbConnectionOptions.cs
- InvalidMessageContractException.cs
- GroupBoxRenderer.cs
- Rfc2898DeriveBytes.cs
- ByteStreamMessage.cs
- ComAdminInterfaces.cs
- ZipIOFileItemStream.cs
- RequestQueue.cs
- TraceHandler.cs
- ServiceOperation.cs
- EventListenerClientSide.cs
- SatelliteContractVersionAttribute.cs
- activationcontext.cs
- TypeUtil.cs
- SqlBulkCopyColumnMapping.cs
- ConfigurationValues.cs
- MarginsConverter.cs
- _ProxyChain.cs
- ToolStripDropDownMenu.cs
- Compiler.cs
- CompoundFileIOPermission.cs
- DataServiceProviderWrapper.cs
- TableParagraph.cs
- HttpsHostedTransportConfiguration.cs
- ItemTypeToolStripMenuItem.cs
- GroupDescription.cs
- _ConnectionGroup.cs
- Size3DConverter.cs
- ScalarType.cs
- TemplatedWizardStep.cs
- BinaryConverter.cs
- BuildManagerHost.cs
- PageOutputColor.cs
- embossbitmapeffect.cs
- ComponentSerializationService.cs
- TextEffectCollection.cs
- UserNamePasswordServiceCredential.cs
- ElementMarkupObject.cs
- ControlIdConverter.cs
- CatalogZoneDesigner.cs
- SpotLight.cs
- WebPermission.cs
- TiffBitmapEncoder.cs
- XamlSerializer.cs
- sitestring.cs
- Choices.cs
- SafeNativeMemoryHandle.cs
- Blend.cs
- Messages.cs
- OpenFileDialog.cs
- AssemblyAttributesGoHere.cs
- UnionCodeGroup.cs
- SmtpFailedRecipientException.cs
- CngAlgorithm.cs
- ThreadNeutralSemaphore.cs
- SmtpReplyReaderFactory.cs
- DashStyle.cs
- MergeExecutor.cs
- CacheAxisQuery.cs
- ConnectionProviderAttribute.cs
- ActivationWorker.cs
- BasicBrowserDialog.cs
- DateTimeOffset.cs
- LongMinMaxAggregationOperator.cs
- cookieexception.cs
- Latin1Encoding.cs
- BoundPropertyEntry.cs
- InheritanceContextChangedEventManager.cs
- ControlCachePolicy.cs
- TimelineCollection.cs
- nulltextnavigator.cs
- LinearGradientBrush.cs
- SerializationFieldInfo.cs
- DependencyPropertyKind.cs
- SoapTypeAttribute.cs
- UnsafeNativeMethods.cs
- TextEditorSpelling.cs
- HttpListener.cs
- TransformGroup.cs
- VisualTreeUtils.cs
- LocalsItemDescription.cs
- ServiceTimeoutsElement.cs
- DynamicUpdateCommand.cs
- LinqDataSourceValidationException.cs
- RuntimeCompatibilityAttribute.cs
- SqlDataSourceConfigureSelectPanel.cs
- FileIOPermission.cs
- DefaultWorkflowLoaderService.cs
- XamlStyleSerializer.cs
- HttpDictionary.cs
- UriTemplateMatchException.cs
- ByteConverter.cs
- SafeThreadHandle.cs
- CodeGenerator.cs