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
- Int32EqualityComparer.cs
- BitmapImage.cs
- GenericEnumerator.cs
- EntityDataSourceChangedEventArgs.cs
- ResourceExpressionBuilder.cs
- Types.cs
- DataGridViewControlCollection.cs
- RegexCaptureCollection.cs
- ConditionalWeakTable.cs
- RowVisual.cs
- BitmapScalingModeValidation.cs
- SlipBehavior.cs
- SqlCacheDependencySection.cs
- SqlAliasesReferenced.cs
- ModelPerspective.cs
- ResourceSet.cs
- DesignBindingEditor.cs
- ZipIOExtraFieldZip64Element.cs
- EmbeddedMailObject.cs
- SoapDocumentServiceAttribute.cs
- dataprotectionpermissionattribute.cs
- UrlMappingsSection.cs
- NavigationProperty.cs
- ThicknessKeyFrameCollection.cs
- DateTimeUtil.cs
- TabletCollection.cs
- PropertyDescriptor.cs
- IntSecurity.cs
- Light.cs
- Int64Converter.cs
- ArgumentOutOfRangeException.cs
- LinkedList.cs
- HttpPostedFile.cs
- HtmlTernaryTree.cs
- Logging.cs
- RbTree.cs
- Int64AnimationUsingKeyFrames.cs
- CardSpaceException.cs
- TimeIntervalCollection.cs
- RootBrowserWindowAutomationPeer.cs
- VolatileEnlistmentMultiplexing.cs
- RefreshEventArgs.cs
- ParameterEditorUserControl.cs
- StylusPointCollection.cs
- ColumnMapCopier.cs
- ActiveDocumentEvent.cs
- ConfigXmlCDataSection.cs
- ModelVisual3D.cs
- PerfProviderCollection.cs
- SessionPageStatePersister.cs
- DoubleLinkListEnumerator.cs
- ConnectionConsumerAttribute.cs
- UnsafeNativeMethods.cs
- Frame.cs
- HttpModulesSection.cs
- QualificationDataAttribute.cs
- MenuTracker.cs
- DotExpr.cs
- ToggleButton.cs
- ToolStripComboBox.cs
- EnumType.cs
- PenContexts.cs
- VerbConverter.cs
- IgnoreFileBuildProvider.cs
- SingleConverter.cs
- DockingAttribute.cs
- DispatcherSynchronizationContext.cs
- ConfigurationStrings.cs
- ResolveCriteriaApril2005.cs
- BatchStream.cs
- ListView.cs
- ActivationServices.cs
- ConfigXmlCDataSection.cs
- Matrix3D.cs
- BehaviorEditorPart.cs
- AuthenticationSection.cs
- GlyphsSerializer.cs
- ReliabilityContractAttribute.cs
- RemoteWebConfigurationHostStream.cs
- CodeComment.cs
- AssemblyFilter.cs
- InstancePersistenceContext.cs
- ContextDataSourceView.cs
- SqlUdtInfo.cs
- BulletChrome.cs
- ValidationEventArgs.cs
- UmAlQuraCalendar.cs
- Vector3DCollection.cs
- ProfileModule.cs
- KeyedPriorityQueue.cs
- SecureConversationDriver.cs
- EmptyReadOnlyDictionaryInternal.cs
- ChangeBlockUndoRecord.cs
- GridPattern.cs
- StrongNamePublicKeyBlob.cs
- InstanceLockLostException.cs
- MachineKeySection.cs
- DrawListViewSubItemEventArgs.cs
- ConnectionsZone.cs
- OpenFileDialog.cs