Code:
/ 4.0 / 4.0 / 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. 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 ICollection object 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
- ScrollEventArgs.cs
- RichTextBoxConstants.cs
- ToolStripDropDown.cs
- SessionStateItemCollection.cs
- ProfileProvider.cs
- _SingleItemRequestCache.cs
- Compress.cs
- ProtocolViolationException.cs
- ClientScriptManagerWrapper.cs
- Int32RectConverter.cs
- LazyTextWriterCreator.cs
- ScrollChrome.cs
- DataServiceSaveChangesEventArgs.cs
- Int16Animation.cs
- BevelBitmapEffect.cs
- ParserExtension.cs
- GeometryConverter.cs
- PngBitmapEncoder.cs
- ReferenceConverter.cs
- NavigationProperty.cs
- FrameSecurityDescriptor.cs
- DispatchWrapper.cs
- CuspData.cs
- MenuItemCollection.cs
- FileDialogPermission.cs
- GridViewActionList.cs
- DeflateEmulationStream.cs
- TableProviderWrapper.cs
- ClientConfigurationHost.cs
- LowerCaseStringConverter.cs
- GenericArgumentsUpdater.cs
- TextModifier.cs
- JsonGlobals.cs
- BamlLocalizableResource.cs
- MailMessageEventArgs.cs
- PKCS1MaskGenerationMethod.cs
- BulletedListEventArgs.cs
- UnsafeNativeMethods.cs
- DesignObjectWrapper.cs
- XmlDownloadManager.cs
- RawStylusSystemGestureInputReport.cs
- MenuCommands.cs
- WebPartConnectionCollection.cs
- GacUtil.cs
- MimeMapping.cs
- XamlTypeMapper.cs
- CodeFieldReferenceExpression.cs
- Calendar.cs
- CompositionAdorner.cs
- DocumentEventArgs.cs
- ListViewItemCollectionEditor.cs
- WindowsRebar.cs
- ParentUndoUnit.cs
- WebRequest.cs
- DbCommandDefinition.cs
- DesigntimeLicenseContext.cs
- UndoEngine.cs
- SchemaTypeEmitter.cs
- IndentTextWriter.cs
- VisualBasicSettingsConverter.cs
- XhtmlConformanceSection.cs
- RecipientInfo.cs
- BufferedOutputStream.cs
- Rotation3DKeyFrameCollection.cs
- StatusBarPanelClickEvent.cs
- ValueUnavailableException.cs
- DataServiceHostFactory.cs
- RadioButton.cs
- QuaternionAnimation.cs
- Property.cs
- ContextMenuStripGroupCollection.cs
- CustomAssemblyResolver.cs
- WaveHeader.cs
- MemberProjectedSlot.cs
- SamlConstants.cs
- AliasedSlot.cs
- SessionStateUtil.cs
- SelectionItemPattern.cs
- PathFigureCollectionValueSerializer.cs
- WindowsStatic.cs
- SafeNativeMethods.cs
- DbDataSourceEnumerator.cs
- FixUpCollection.cs
- CompositionAdorner.cs
- CommonObjectSecurity.cs
- RawKeyboardInputReport.cs
- SelectorItemAutomationPeer.cs
- UserControlCodeDomTreeGenerator.cs
- figurelengthconverter.cs
- ProxyWebPartConnectionCollection.cs
- SnapLine.cs
- SelectionListComponentEditor.cs
- HostedHttpTransportManager.cs
- WebBaseEventKeyComparer.cs
- InputBinding.cs
- SqlUserDefinedTypeAttribute.cs
- PropertyCollection.cs
- GZipStream.cs
- IssuedTokenClientElement.cs
- RtfControls.cs