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
- XmlValueConverter.cs
- LogEntrySerializer.cs
- XmlUnspecifiedAttribute.cs
- WizardPanelChangingEventArgs.cs
- ResetableIterator.cs
- DefinitionBase.cs
- DistinctQueryOperator.cs
- OleTxTransactionInfo.cs
- SqlCacheDependencyDatabaseCollection.cs
- PlanCompilerUtil.cs
- UserInitiatedRoutedEventPermissionAttribute.cs
- ReverseInheritProperty.cs
- OutputWindow.cs
- SafeEventLogWriteHandle.cs
- ISFClipboardData.cs
- SemaphoreFullException.cs
- TraceInternal.cs
- SafeBitVector32.cs
- RadioButtonAutomationPeer.cs
- DeflateEmulationStream.cs
- SocketElement.cs
- Rfc4050KeyFormatter.cs
- SafeProcessHandle.cs
- XmlQueryContext.cs
- FileSystemWatcher.cs
- ConnectionInterfaceCollection.cs
- SqlTransaction.cs
- TimeStampChecker.cs
- SrgsRulesCollection.cs
- BulletDecorator.cs
- AuthorizationRuleCollection.cs
- ContextMarshalException.cs
- SchemaMerger.cs
- EditorPartCollection.cs
- MethodBody.cs
- SqlDataSourceConfigureSortForm.cs
- ByteStream.cs
- SafeBitVector32.cs
- SafeNativeMethods.cs
- Vars.cs
- DetailsViewPagerRow.cs
- PathParser.cs
- MessageTransmitTraceRecord.cs
- GenericXmlSecurityToken.cs
- UIAgentAsyncBeginRequest.cs
- AssemblyResourceLoader.cs
- HebrewNumber.cs
- UnauthorizedAccessException.cs
- PolicyException.cs
- QuaternionAnimation.cs
- RSAPKCS1SignatureDeformatter.cs
- ProgressBar.cs
- StatusInfoItem.cs
- LayoutExceptionEventArgs.cs
- InnerItemCollectionView.cs
- GridViewDeleteEventArgs.cs
- NetStream.cs
- FormViewUpdatedEventArgs.cs
- ElementAction.cs
- AesManaged.cs
- TypeUtil.cs
- EdmTypeAttribute.cs
- InputMethod.cs
- FontFamilyConverter.cs
- WebPartConnectionsEventArgs.cs
- AppliedDeviceFiltersDialog.cs
- MouseGestureValueSerializer.cs
- HttpPostedFileBase.cs
- HttpContext.cs
- PropertyInformation.cs
- ProfileModule.cs
- URLEditor.cs
- XmlSerializerAssemblyAttribute.cs
- DetailsViewInsertEventArgs.cs
- HtmlToClrEventProxy.cs
- PropertiesTab.cs
- __TransparentProxy.cs
- VisualStateGroup.cs
- ToolStripLocationCancelEventArgs.cs
- XPathException.cs
- ToolstripProfessionalRenderer.cs
- ConnectionsZone.cs
- PasswordRecoveryDesigner.cs
- WebControlsSection.cs
- ProjectedSlot.cs
- BeginStoryboard.cs
- XPathNavigatorKeyComparer.cs
- PageSettings.cs
- TextFormatterContext.cs
- GridViewColumnCollectionChangedEventArgs.cs
- Types.cs
- TextChange.cs
- PropertyDescriptor.cs
- SRGSCompiler.cs
- X509ClientCertificateAuthenticationElement.cs
- __FastResourceComparer.cs
- TypeUtil.cs
- AnnotationComponentManager.cs
- TextTrailingCharacterEllipsis.cs
- DrawingAttributes.cs