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
- CodeSnippetExpression.cs
- TraceHandlerErrorFormatter.cs
- BinaryMethodMessage.cs
- TimerElapsedEvenArgs.cs
- GeometryModel3D.cs
- UserPersonalizationStateInfo.cs
- RadioButton.cs
- OpCopier.cs
- Win32Native.cs
- WebDescriptionAttribute.cs
- CurrentTimeZone.cs
- GorillaCodec.cs
- DBSchemaRow.cs
- ComponentCommands.cs
- MarkupExtensionSerializer.cs
- ConfigurationSectionHelper.cs
- Roles.cs
- PropertySegmentSerializer.cs
- MultilineStringEditor.cs
- FixedTextSelectionProcessor.cs
- QuestionEventArgs.cs
- XmlUrlResolver.cs
- CodeDirectiveCollection.cs
- RecordsAffectedEventArgs.cs
- cryptoapiTransform.cs
- __Error.cs
- XmlArrayAttribute.cs
- UnsafeNativeMethods.cs
- SwitchElementsCollection.cs
- Pts.cs
- SpotLight.cs
- MediaTimeline.cs
- AnimatedTypeHelpers.cs
- ItemCheckEvent.cs
- InstanceKey.cs
- lengthconverter.cs
- Line.cs
- References.cs
- ViewgenContext.cs
- DataGridViewCellPaintingEventArgs.cs
- XmlSchemaChoice.cs
- TreeView.cs
- ScriptReference.cs
- ZoneIdentityPermission.cs
- AuthenticationModeHelper.cs
- ListQueryResults.cs
- WebScriptMetadataMessageEncoderFactory.cs
- Base64Decoder.cs
- SqlServices.cs
- SqlCacheDependencySection.cs
- WpfKnownMember.cs
- XPathExpr.cs
- Expander.cs
- EventSourceCreationData.cs
- XPathParser.cs
- ProfileSection.cs
- DataFieldConverter.cs
- BmpBitmapEncoder.cs
- __FastResourceComparer.cs
- diagnosticsswitches.cs
- PermissionSetEnumerator.cs
- OdbcDataReader.cs
- DivideByZeroException.cs
- ClientCultureInfo.cs
- FileInfo.cs
- DocumentViewerConstants.cs
- GroupQuery.cs
- ActiveXHelper.cs
- RelatedCurrencyManager.cs
- Block.cs
- DataServicePagingProviderWrapper.cs
- CodeCatchClause.cs
- XsltOutput.cs
- CharKeyFrameCollection.cs
- DbFunctionCommandTree.cs
- Simplifier.cs
- DiscoveryExceptionDictionary.cs
- SectionUpdates.cs
- rsa.cs
- ReadOnlyDictionary.cs
- Int32.cs
- SystemIPGlobalStatistics.cs
- MetadataArtifactLoader.cs
- SystemResources.cs
- ColumnReorderedEventArgs.cs
- ShaderRenderModeValidation.cs
- LowerCaseStringConverter.cs
- CompensatableTransactionScopeActivityDesigner.cs
- HtmlControl.cs
- DataPagerFieldCommandEventArgs.cs
- DelegatedStream.cs
- X509Logo.cs
- UriSection.cs
- ListItem.cs
- FilteredSchemaElementLookUpTable.cs
- Type.cs
- RNGCryptoServiceProvider.cs
- ResourceDictionaryCollection.cs
- DataGridViewColumnEventArgs.cs
- Stroke2.cs