Code:
/ 4.0 / 4.0 / 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. 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) { IDictionary store = 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
- DataSourceHelper.cs
- SingleConverter.cs
- SingleStorage.cs
- SecurityKeyUsage.cs
- SchemaElement.cs
- FullTextBreakpoint.cs
- XMLDiffLoader.cs
- AutomationElementIdentifiers.cs
- dataprotectionpermissionattribute.cs
- Parameter.cs
- MessageHeaderDescriptionCollection.cs
- ReadOnlyDictionary.cs
- AutoResizedEvent.cs
- CommandValueSerializer.cs
- Debugger.cs
- ExpressionConverter.cs
- XpsDigitalSignature.cs
- ArgumentException.cs
- MemberInfoSerializationHolder.cs
- CodeDomSerializerBase.cs
- ProfileSection.cs
- IdleTimeoutMonitor.cs
- WorkflowMarkupSerializerMapping.cs
- CommonXSendMessage.cs
- ModifierKeysConverter.cs
- UnsafeNativeMethods.cs
- NewItemsContextMenuStrip.cs
- WebPartRestoreVerb.cs
- StandardToolWindows.cs
- SudsCommon.cs
- SemaphoreFullException.cs
- SchemaHelper.cs
- HyperLinkDataBindingHandler.cs
- AnimationStorage.cs
- DataGridViewHitTestInfo.cs
- ListManagerBindingsCollection.cs
- Mapping.cs
- AssemblyInfo.cs
- SqlVisitor.cs
- TypeReference.cs
- New.cs
- PrintDocument.cs
- NativeMethods.cs
- TreeNodeStyleCollection.cs
- Registration.cs
- MenuDesigner.cs
- XmlReaderSettings.cs
- ResXResourceWriter.cs
- HtmlInputCheckBox.cs
- PasswordTextNavigator.cs
- AutomationTextAttribute.cs
- LinkLabel.cs
- Listbox.cs
- DoubleConverter.cs
- TaskFileService.cs
- FieldTemplateUserControl.cs
- HeaderFilter.cs
- StrokeNode.cs
- ClientProxyGenerator.cs
- SubstitutionList.cs
- SafeRegistryHandle.cs
- ComAwareEventInfo.cs
- XmlILModule.cs
- WebScriptMetadataMessageEncodingBindingElement.cs
- httpserverutility.cs
- SingleTagSectionHandler.cs
- KeyboardNavigation.cs
- Brush.cs
- CodeSnippetStatement.cs
- CustomTypeDescriptor.cs
- AsyncOperation.cs
- AssemblyBuilderData.cs
- BrowserCapabilitiesCodeGenerator.cs
- PauseStoryboard.cs
- RichListBox.cs
- TablePattern.cs
- XmlLoader.cs
- AnnouncementClient.cs
- FontFamilyIdentifier.cs
- CapabilitiesState.cs
- SimpleWorkerRequest.cs
- HtmlTextArea.cs
- TextRangeEditLists.cs
- NotifyParentPropertyAttribute.cs
- XmlIlVisitor.cs
- WebPartDescriptionCollection.cs
- DtdParser.cs
- NoPersistHandle.cs
- IssuanceLicense.cs
- TextBoxAutoCompleteSourceConverter.cs
- TdsParserHelperClasses.cs
- DataSourceCacheDurationConverter.cs
- IOThreadTimer.cs
- Behavior.cs
- DebugInfoExpression.cs
- WaitHandleCannotBeOpenedException.cs
- EndpointIdentityExtension.cs
- Pen.cs
- ExternalException.cs
- RegionInfo.cs