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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SoapAttributeOverrides.cs
- precedingsibling.cs
- StringValidatorAttribute.cs
- PointAnimation.cs
- StylusEditingBehavior.cs
- XmlSchemaSequence.cs
- EventBuilder.cs
- Bold.cs
- InputReport.cs
- JapaneseCalendar.cs
- ImplicitInputBrush.cs
- ColumnBinding.cs
- Encoding.cs
- GreenMethods.cs
- OracleBFile.cs
- XmlNodeComparer.cs
- XmlWriterTraceListener.cs
- CapabilitiesState.cs
- ClientData.cs
- BackStopAuthenticationModule.cs
- ToolStripTextBox.cs
- XhtmlBasicValidatorAdapter.cs
- HttpModulesSection.cs
- MouseButton.cs
- FontDriver.cs
- WmlLinkAdapter.cs
- Duration.cs
- RelatedPropertyManager.cs
- ColumnMap.cs
- XPathDocumentBuilder.cs
- AsmxEndpointPickerExtension.cs
- ReflectionPermission.cs
- DataRelationCollection.cs
- InvalidDataContractException.cs
- DataExchangeServiceBinder.cs
- _ProxyChain.cs
- SyntaxCheck.cs
- SchemaMerger.cs
- XamlBuildProvider.cs
- DataTableReaderListener.cs
- ResolveResponse.cs
- ConfigurationManagerInternalFactory.cs
- PolyLineSegmentFigureLogic.cs
- DurableOperationContext.cs
- AssociationSetMetadata.cs
- DesignSurfaceCollection.cs
- GlobalEventManager.cs
- Geometry3D.cs
- _NegotiateClient.cs
- Helpers.cs
- PowerModeChangedEventArgs.cs
- ResourceContainer.cs
- ContentHostHelper.cs
- GlyphInfoList.cs
- ThreadInterruptedException.cs
- WebPartEventArgs.cs
- BooleanAnimationUsingKeyFrames.cs
- DocumentXmlWriter.cs
- ProcessExitedException.cs
- ParserStack.cs
- UnaryOperationBinder.cs
- ImmutableObjectAttribute.cs
- XmlMembersMapping.cs
- RangeValidator.cs
- DataGridRow.cs
- ReturnType.cs
- MethodSet.cs
- x509store.cs
- AccessText.cs
- RepeatBehaviorConverter.cs
- WebPartAuthorizationEventArgs.cs
- MSAAWinEventWrap.cs
- FileDialogCustomPlacesCollection.cs
- WebReferenceCollection.cs
- CollectionConverter.cs
- BindingValueChangedEventArgs.cs
- HttpException.cs
- DataGridViewEditingControlShowingEventArgs.cs
- Nullable.cs
- RuntimeArgumentHandle.cs
- HierarchicalDataBoundControl.cs
- ContentDisposition.cs
- StoragePropertyMapping.cs
- MemberAccessException.cs
- TimeManager.cs
- TransformCryptoHandle.cs
- DocumentGridPage.cs
- TemplateNodeContextMenu.cs
- TableItemPattern.cs
- SchemaInfo.cs
- OdbcErrorCollection.cs
- Int16AnimationUsingKeyFrames.cs
- XmlChoiceIdentifierAttribute.cs
- PanelStyle.cs
- SaveRecipientRequest.cs
- SqlInternalConnection.cs
- EFDataModelProvider.cs
- Point3DCollection.cs
- DbConnectionStringBuilder.cs
- JsonReaderWriterFactory.cs