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
- HMACRIPEMD160.cs
- Vector.cs
- XmlProcessingInstruction.cs
- PasswordPropertyTextAttribute.cs
- SystemColors.cs
- CharacterHit.cs
- Command.cs
- TextPattern.cs
- RSAProtectedConfigurationProvider.cs
- XmlDomTextWriter.cs
- DotExpr.cs
- LoginName.cs
- CornerRadiusConverter.cs
- RuleSettings.cs
- BoundPropertyEntry.cs
- LoginView.cs
- DesignerProperties.cs
- PeerTransportBindingElement.cs
- SecurityDocument.cs
- InterleavedZipPartStream.cs
- XmlSchemaInclude.cs
- SqlInternalConnection.cs
- SymmetricKey.cs
- HostingEnvironmentException.cs
- SystemDropShadowChrome.cs
- _DigestClient.cs
- HWStack.cs
- RelationshipEndCollection.cs
- MenuItem.cs
- PackageRelationshipSelector.cs
- ZipIORawDataFileBlock.cs
- TableProviderWrapper.cs
- COM2PropertyDescriptor.cs
- SpellerError.cs
- Vector3DKeyFrameCollection.cs
- ObjectListShowCommandsEventArgs.cs
- ToolZoneDesigner.cs
- SignedXmlDebugLog.cs
- GlyphRunDrawing.cs
- DropShadowBitmapEffect.cs
- ColorAnimation.cs
- BinaryNode.cs
- ExecutionScope.cs
- PropertyGridCommands.cs
- EventTrigger.cs
- ImageList.cs
- FieldBuilder.cs
- ValueCollectionParameterReader.cs
- exports.cs
- MetaDataInfo.cs
- ThemeableAttribute.cs
- SingleAnimation.cs
- MappedMetaModel.cs
- ProfileModule.cs
- PersonalizationStateQuery.cs
- ToolStripItem.cs
- BigInt.cs
- ProtocolsConfiguration.cs
- MasterPageBuildProvider.cs
- StorageBasedPackageProperties.cs
- TextChange.cs
- PasswordRecovery.cs
- SqlStream.cs
- FixedSOMTextRun.cs
- HtmlTitle.cs
- List.cs
- DataServiceClientException.cs
- MailMessageEventArgs.cs
- MappedMetaModel.cs
- ConnectionsZone.cs
- WorkflowRuntimeElement.cs
- PixelFormat.cs
- QuaternionConverter.cs
- FixedFlowMap.cs
- HtmlInputSubmit.cs
- InternalTypeHelper.cs
- BooleanFacetDescriptionElement.cs
- PrimitiveRenderer.cs
- TextServicesCompartmentEventSink.cs
- WindowsTokenRoleProvider.cs
- ViewManager.cs
- IdnMapping.cs
- ItemChangedEventArgs.cs
- HtmlValidatorAdapter.cs
- ToolStripDropDownItem.cs
- Bind.cs
- _SslState.cs
- BooleanProjectedSlot.cs
- UnknownWrapper.cs
- ExpressionEditorAttribute.cs
- AutomationElement.cs
- filewebresponse.cs
- HttpRawResponse.cs
- XmlSchemaValidator.cs
- GuidelineSet.cs
- ChannelSinkStacks.cs
- PersonalizablePropertyEntry.cs
- URI.cs
- ChannelSinkStacks.cs
- SoapRpcServiceAttribute.cs