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
- RtfNavigator.cs
- ToggleButton.cs
- JsonQueryStringConverter.cs
- RowParagraph.cs
- AssemblyCache.cs
- BitmapCacheBrush.cs
- WebPageTraceListener.cs
- BufferedGraphicsManager.cs
- ReadOnlyCollectionBuilder.cs
- ServiceDebugBehavior.cs
- DisplayNameAttribute.cs
- ItemAutomationPeer.cs
- InkCanvasFeedbackAdorner.cs
- HeaderElement.cs
- DrawingAttributes.cs
- FlowDocumentPageViewerAutomationPeer.cs
- RecognizedAudio.cs
- RoleGroup.cs
- StateMachineSubscription.cs
- MonthChangedEventArgs.cs
- BindingCompleteEventArgs.cs
- TransformProviderWrapper.cs
- FixedTextPointer.cs
- ProviderConnectionPointCollection.cs
- SendingRequestEventArgs.cs
- ISAPIRuntime.cs
- IconHelper.cs
- InputDevice.cs
- DragEventArgs.cs
- AsyncStreamReader.cs
- MessageSecurityVersionConverter.cs
- NullExtension.cs
- DataTableReaderListener.cs
- DataRelationCollection.cs
- EmptyStringExpandableObjectConverter.cs
- DataSourceCacheDurationConverter.cs
- DataTableReaderListener.cs
- ObjectStateEntry.cs
- ScriptingAuthenticationServiceSection.cs
- StylusOverProperty.cs
- ISFTagAndGuidCache.cs
- SmtpNetworkElement.cs
- _LazyAsyncResult.cs
- TrustManagerMoreInformation.cs
- CommandHelpers.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- ObjectPropertyMapping.cs
- PerformanceCounterLib.cs
- NativeMethods.cs
- RegistryExceptionHelper.cs
- ContainerControl.cs
- DecimalAnimationUsingKeyFrames.cs
- CodeSnippetTypeMember.cs
- XmlSecureResolver.cs
- GridSplitterAutomationPeer.cs
- SqlConnectionString.cs
- MetadataArtifactLoaderResource.cs
- HttpValueCollection.cs
- SQLDateTimeStorage.cs
- UIElement3DAutomationPeer.cs
- ModuleConfigurationInfo.cs
- XmlSerializerVersionAttribute.cs
- ContainerControlDesigner.cs
- SliderAutomationPeer.cs
- DEREncoding.cs
- LockCookie.cs
- SQLDateTime.cs
- LambdaCompiler.cs
- ThreadAttributes.cs
- Renderer.cs
- DesignerActionMethodItem.cs
- Int32AnimationBase.cs
- BaseProcessor.cs
- BCLDebug.cs
- OperationResponse.cs
- RequestCachingSection.cs
- ComponentEditorForm.cs
- RIPEMD160.cs
- QueryOutputWriter.cs
- XmlEntityReference.cs
- XmlIlGenerator.cs
- SystemUnicastIPAddressInformation.cs
- ResourceExpressionBuilder.cs
- UpDownEvent.cs
- TableRowCollection.cs
- PasswordTextContainer.cs
- Encoding.cs
- CodeParameterDeclarationExpression.cs
- HtmlProps.cs
- DictionaryEditChange.cs
- RequestCachingSection.cs
- PerspectiveCamera.cs
- InitialServerConnectionReader.cs
- XmlSchemas.cs
- MediaElement.cs
- MustUnderstandSoapException.cs
- WindowsFormsHost.cs
- SqlGatherProducedAliases.cs
- ListItemConverter.cs
- PerformanceCounterLib.cs