Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Serializer / SynchronizationHandlesCodeDomSerializer.cs / 1305376 / SynchronizationHandlesCodeDomSerializer.cs
namespace System.Workflow.ComponentModel.Serialization { using System; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design.Serialization; using System.Workflow.ComponentModel.Compiler; using System.Collections; using System.Collections.Specialized; using System.Collections.Generic; // This serializer will serialize any ICollectionobject into code statements that constructs the collection. // The default serializer serializes the collection as resource because ICollection is serializable. // We originally add this serializer to deal with the SynchronizationHandles property on SynchronizationScopeActivity. // It was a problem because this serializer will be invoked for any property of ICollection type. Now I've // made this generic enough to be used by any such properties. internal sealed class SynchronizationHandlesCodeDomSerializer : CodeDomSerializer { public override object Serialize(IDesignerSerializationManager manager, object obj) { if (manager == null) throw new ArgumentNullException("manager"); if (obj == null) throw new ArgumentNullException("obj"); CodeExpression retVal = null; CodeStatementCollection statements = manager.Context[typeof(CodeStatementCollection)] as CodeStatementCollection; System.Diagnostics.Debug.Assert(statements != null); if (statements != null) { Activity activity = (Activity)manager.Context[typeof(Activity)]; CodeExpression objectExpression = SerializeToExpression(manager, activity); ICollection handles = obj as ICollection ; if (handles == null) throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(StringCollection).FullName), "obj"); string variableName = GetUniqueName(manager, new StringCollection()); statements.Add(new CodeVariableDeclarationStatement(obj.GetType(), variableName, new CodeObjectCreateExpression(obj.GetType()))); foreach (string handle in handles) statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(variableName), "Add"), new CodeExpression[] { new CodePrimitiveExpression(handle) })); retVal = new CodeVariableReferenceExpression(variableName); } return retVal; } } } // 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
- XmlNamedNodeMap.cs
- StreamAsIStream.cs
- StandardOleMarshalObject.cs
- Span.cs
- FrameworkElementFactory.cs
- ToolStripLocationCancelEventArgs.cs
- MenuItemBinding.cs
- SafeEventHandle.cs
- PeerToPeerException.cs
- SqlDependencyListener.cs
- Empty.cs
- LinearGradientBrush.cs
- WebEvents.cs
- FixedTextSelectionProcessor.cs
- ChangeTracker.cs
- HostingEnvironmentException.cs
- _ConnectionGroup.cs
- ReadOnlyHierarchicalDataSourceView.cs
- RowVisual.cs
- DataControlImageButton.cs
- MouseButtonEventArgs.cs
- COM2TypeInfoProcessor.cs
- XhtmlBasicLiteralTextAdapter.cs
- ExpressionVisitorHelpers.cs
- _KerberosClient.cs
- panel.cs
- EntityContainerEntitySetDefiningQuery.cs
- DSASignatureDeformatter.cs
- HighlightVisual.cs
- OleDbCommand.cs
- _HelperAsyncResults.cs
- SeekStoryboard.cs
- Repeater.cs
- XmlTextWriter.cs
- StatusBarItemAutomationPeer.cs
- X500Name.cs
- WindowsListViewItemStartMenu.cs
- TextBoxLine.cs
- compensatingcollection.cs
- StrongBox.cs
- AppDomainManager.cs
- GlobalAllocSafeHandle.cs
- SqlError.cs
- RepeatButton.cs
- Misc.cs
- TimeStampChecker.cs
- WebPartManagerInternals.cs
- GifBitmapEncoder.cs
- FontStretches.cs
- XmlLanguageConverter.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- Message.cs
- _ServiceNameStore.cs
- SortedDictionary.cs
- BitmapMetadata.cs
- XmlMemberMapping.cs
- LayoutInformation.cs
- CounterCreationDataCollection.cs
- XPathNavigator.cs
- XmlCharCheckingWriter.cs
- XamlTypeWithExplicitNamespace.cs
- KeyValuePairs.cs
- StringDictionary.cs
- WindowsStartMenu.cs
- HyperLinkColumn.cs
- KeyedCollection.cs
- DefaultBindingPropertyAttribute.cs
- DynamicQueryStringParameter.cs
- PerformanceCounterCategory.cs
- ValidationHelper.cs
- AutomationPropertyInfo.cs
- TextEvent.cs
- PipeStream.cs
- DbDataAdapter.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- GridItemProviderWrapper.cs
- TextEffect.cs
- MapPathBasedVirtualPathProvider.cs
- GeneralTransform2DTo3DTo2D.cs
- SoapEnumAttribute.cs
- ToolBarTray.cs
- ConfigXmlWhitespace.cs
- DataPointer.cs
- FactoryGenerator.cs
- ShaperBuffers.cs
- SrgsRule.cs
- SchemaMapping.cs
- ValueType.cs
- SignedXml.cs
- ProjectionPruner.cs
- CultureData.cs
- FacetDescriptionElement.cs
- HttpContextBase.cs
- SvcMapFile.cs
- FileLogRecord.cs
- Annotation.cs
- ColumnWidthChangingEvent.cs
- Events.cs
- ActiveXHost.cs
- ValueUnavailableException.cs