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
- HtmlShim.cs
- FileDetails.cs
- ManifestResourceInfo.cs
- Walker.cs
- TextTabProperties.cs
- Validator.cs
- ResourceReferenceKeyNotFoundException.cs
- xdrvalidator.cs
- LogicalTreeHelper.cs
- UnitySerializationHolder.cs
- FixedSOMTableCell.cs
- RichTextBox.cs
- Enum.cs
- ValidationRule.cs
- EdmComplexTypeAttribute.cs
- Focus.cs
- SupportsEventValidationAttribute.cs
- FormsAuthenticationConfiguration.cs
- XmlEncApr2001.cs
- PropertyMappingExceptionEventArgs.cs
- RSAPKCS1KeyExchangeFormatter.cs
- RegexWriter.cs
- CharConverter.cs
- Wildcard.cs
- VirtualPathProvider.cs
- RpcResponse.cs
- PrimitiveSchema.cs
- OperationResponse.cs
- SettingsPropertyWrongTypeException.cs
- ProgramPublisher.cs
- MouseBinding.cs
- altserialization.cs
- UserControlDocumentDesigner.cs
- BindingElement.cs
- ObjectListField.cs
- SQLDouble.cs
- Processor.cs
- ObjectListCommandsPage.cs
- BlurBitmapEffect.cs
- RoleServiceManager.cs
- ObjectStorage.cs
- OuterGlowBitmapEffect.cs
- WeakEventTable.cs
- ComponentGuaranteesAttribute.cs
- HealthMonitoringSection.cs
- PasswordBox.cs
- SymbolType.cs
- Token.cs
- ObjectDataSourceChooseMethodsPanel.cs
- ObjectDataSourceDisposingEventArgs.cs
- columnmapkeybuilder.cs
- FlowLayout.cs
- HttpResponse.cs
- printdlgexmarshaler.cs
- filewebrequest.cs
- ParentUndoUnit.cs
- EntitySqlQueryCacheKey.cs
- GlobalizationAssembly.cs
- MultiPageTextView.cs
- DiscreteKeyFrames.cs
- SqlPersonalizationProvider.cs
- UIInitializationException.cs
- LineVisual.cs
- QueryContext.cs
- Exceptions.cs
- WorkflowDesigner.cs
- DynamicQueryableWrapper.cs
- TypeInformation.cs
- ElementAtQueryOperator.cs
- QilDataSource.cs
- WebZone.cs
- RightsManagementEncryptionTransform.cs
- DbProviderFactoriesConfigurationHandler.cs
- RoleServiceManager.cs
- LinkedDataMemberFieldEditor.cs
- CompletedAsyncResult.cs
- SamlDelegatingWriter.cs
- CanExecuteRoutedEventArgs.cs
- Object.cs
- TextTreeRootNode.cs
- CodeAssignStatement.cs
- HttpProtocolReflector.cs
- VisualStyleInformation.cs
- ReachVisualSerializerAsync.cs
- TreeViewItem.cs
- FlowDocumentPageViewerAutomationPeer.cs
- ArgumentOutOfRangeException.cs
- Msec.cs
- DocumentOutline.cs
- SapiGrammar.cs
- FileNotFoundException.cs
- ControlPaint.cs
- HierarchicalDataSourceControl.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- WebUtil.cs
- AssemblyFilter.cs
- GenericAuthenticationEventArgs.cs
- TokenBasedSetEnumerator.cs
- MessageHeader.cs
- CodeAccessSecurityEngine.cs