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
- StylusShape.cs
- ToggleButtonAutomationPeer.cs
- AutoCompleteStringCollection.cs
- PageTheme.cs
- HMACSHA512.cs
- ReservationNotFoundException.cs
- DataGridToolTip.cs
- Accessors.cs
- TextBoxAutoCompleteSourceConverter.cs
- CollectionBase.cs
- TaskHelper.cs
- Int32CAMarshaler.cs
- ToolBarOverflowPanel.cs
- PublisherIdentityPermission.cs
- SoapExtensionReflector.cs
- XmlSchemaNotation.cs
- BinHexDecoder.cs
- BadImageFormatException.cs
- TrackingRecordPreFilter.cs
- ElementNotEnabledException.cs
- PeerNameRecordCollection.cs
- AttributeConverter.cs
- XmlSerializerFaultFormatter.cs
- ToolStripGripRenderEventArgs.cs
- HtmlForm.cs
- _CommandStream.cs
- CultureNotFoundException.cs
- LineMetrics.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- HatchBrush.cs
- DocumentStatusResources.cs
- List.cs
- TypeElementCollection.cs
- HttpDictionary.cs
- CodeGroup.cs
- BaseCodeDomTreeGenerator.cs
- TreeIterator.cs
- DataGridViewCellValidatingEventArgs.cs
- VersionedStreamOwner.cs
- Merger.cs
- LocatorGroup.cs
- HTTPNotFoundHandler.cs
- AliasExpr.cs
- SimpleLine.cs
- XPathNavigator.cs
- RouteParser.cs
- SaveRecipientRequest.cs
- ApplicationId.cs
- OperationContractAttribute.cs
- WhitespaceReader.cs
- TdsParserStateObject.cs
- HttpProfileGroupBase.cs
- ListView.cs
- RelationalExpressions.cs
- ResourcePermissionBaseEntry.cs
- TcpSocketManager.cs
- IItemProperties.cs
- BooleanConverter.cs
- CellQuery.cs
- DependencyObjectPropertyDescriptor.cs
- MachineKeySection.cs
- TemplateBamlRecordReader.cs
- QilFactory.cs
- HttpFileCollection.cs
- CacheChildrenQuery.cs
- FontEmbeddingManager.cs
- XmlBoundElement.cs
- NativeMethods.cs
- Vector3DAnimation.cs
- DocumentSequenceHighlightLayer.cs
- ReadOnlyMetadataCollection.cs
- InfocardExtendedInformationEntry.cs
- BindingValueChangedEventArgs.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- DataBindingList.cs
- FontStyles.cs
- WeakEventTable.cs
- DesignerObjectListAdapter.cs
- WizardPanel.cs
- _SslStream.cs
- HtmlTextViewAdapter.cs
- securitymgrsite.cs
- DataPager.cs
- ProvidersHelper.cs
- CustomError.cs
- CmsUtils.cs
- DelayedRegex.cs
- RecordConverter.cs
- HtmlInputImage.cs
- VirtualDirectoryMapping.cs
- CounterCreationDataConverter.cs
- Utility.cs
- DateTimeFormatInfoScanner.cs
- HttpStreamMessageEncoderFactory.cs
- StorageModelBuildProvider.cs
- OutOfMemoryException.cs
- SafeNativeHandle.cs
- ChannelAcceptor.cs
- UserInitiatedNavigationPermission.cs
- OleDbInfoMessageEvent.cs