Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Core.Presentation / System / Activities / Core / Presentation / MorphHelpers.cs / 1305376 / MorphHelpers.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Core.Presentation { using System; using System.Activities.Presentation.Model; using System.Activities.Presentation.Hosting; using System.ComponentModel; using Microsoft.VisualBasic.Activities; using System.Runtime; using System.Linq; using System.Activities.Expressions; using System.Activities.Presentation.View; using System.Collections.Generic; using System.Activities.ExpressionParser; using System.Diagnostics; using System.Globalization; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.IO; using System.Activities.Presentation; static class MorphHelpers { public static object ArgumentMorphHelper(ModelItem originalValue, ModelProperty newModelProperty) { Type expressionTypeArgument = newModelProperty.PropertyType.GetGenericArguments()[0]; return MorphArgument(originalValue, expressionTypeArgument); } internal static Argument MorphArgument(ModelItem originalValue, Type targetType) { Argument morphed = null; Argument original = (Argument)originalValue.GetCurrentValue(); if (original.Expression != null) { Type expressionType = original.Expression.GetType(); Type expressionGenericType = expressionType.IsGenericType ? expressionType.GetGenericTypeDefinition() : null; if (expressionGenericType != null) { string expressionText = ExpressionHelper.GetExpressionString(original.Expression); ActivityWithResult morphedExpression = ExpressionHelper.CreateExpression(targetType, expressionText, expressionGenericType == typeof(VisualBasicReference<>), null); morphed = Argument.Create(targetType, original.Direction); morphed.Expression = morphedExpression; } } return morphed; } public static object ActivityActionMorphHelper(ModelItem originalValue, ModelProperty newModelProperty) { Fx.Assert(newModelProperty.PropertyType.GetGenericArguments().Count() == 1, "This should only be applied for ActivityAction"); Type activityActionTypeArgument = newModelProperty.PropertyType.GetGenericArguments()[0]; Type activityActionType = typeof(ActivityAction<>).MakeGenericType(activityActionTypeArgument); object activityAction = Activator.CreateInstance(activityActionType); ModelItem morphed = ModelFactory.CreateItem(originalValue.GetEditingContext(), activityAction); ModelItem originalActivityActionArgument = originalValue.Properties[PropertyNames.ActionArgument].Value; if (originalActivityActionArgument != null) { Type variableType = typeof(DelegateInArgument<>).MakeGenericType(activityActionTypeArgument); DelegateInArgument iterationDelegateArgument = (DelegateInArgument)Activator.CreateInstance(variableType); iterationDelegateArgument.Name = (string)originalActivityActionArgument.Properties[PropertyNames.NameProperty].Value.GetCurrentValue(); morphed.Properties[PropertyNames.ActionArgument].SetValue(iterationDelegateArgument); } ModelItem originalActivityActionHandler = originalValue.Properties[PropertyNames.ActionHandler].Value; if (originalActivityActionHandler != null) { morphed.Properties[PropertyNames.ActionHandler].SetValue(originalActivityActionHandler); originalValue.Properties[PropertyNames.ActionHandler].SetValue(null); } return morphed; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RegionIterator.cs
- DataFormats.cs
- GiveFeedbackEvent.cs
- DataGridTable.cs
- MobileCapabilities.cs
- DesignerTransactionCloseEvent.cs
- ConsumerConnectionPoint.cs
- Int32CAMarshaler.cs
- TextHintingModeValidation.cs
- XmlSchemaSequence.cs
- RegularExpressionValidator.cs
- safemediahandle.cs
- Calendar.cs
- AuthenticationModuleElementCollection.cs
- OracleCommandBuilder.cs
- ScrollChangedEventArgs.cs
- SmtpDateTime.cs
- StreamReader.cs
- MatrixStack.cs
- Menu.cs
- TrustSection.cs
- DebugView.cs
- TagNameToTypeMapper.cs
- ShaderRenderModeValidation.cs
- AppendHelper.cs
- UIElementAutomationPeer.cs
- RotateTransform.cs
- DataStreamFromComStream.cs
- ScriptBehaviorDescriptor.cs
- OleDbError.cs
- DataTableCollection.cs
- WebPartEditorCancelVerb.cs
- DocumentPage.cs
- XmlSchema.cs
- TextView.cs
- BitHelper.cs
- LineProperties.cs
- BuildProvidersCompiler.cs
- StreamWriter.cs
- PngBitmapEncoder.cs
- RectangleGeometry.cs
- ComEventsHelper.cs
- SimplePropertyEntry.cs
- embossbitmapeffect.cs
- RequestCacheValidator.cs
- WebPartManagerInternals.cs
- FlowDocumentPageViewerAutomationPeer.cs
- DirectoryGroupQuery.cs
- LambdaReference.cs
- EventItfInfo.cs
- BindingParameterCollection.cs
- WorkflowRuntimeBehavior.cs
- NetPipeSection.cs
- DoWorkEventArgs.cs
- XmlSchemaComplexContentRestriction.cs
- AcceptorSessionSymmetricTransportSecurityProtocol.cs
- SocketPermission.cs
- PictureBoxDesigner.cs
- NavigationEventArgs.cs
- CompressionTracing.cs
- ConnectionPointCookie.cs
- remotingproxy.cs
- HttpContext.cs
- SponsorHelper.cs
- DataException.cs
- CodeTypeReference.cs
- MaskedTextProvider.cs
- ManifestResourceInfo.cs
- GrammarBuilderPhrase.cs
- SafeUserTokenHandle.cs
- InputLangChangeEvent.cs
- AlphaSortedEnumConverter.cs
- LinkAreaEditor.cs
- JsonQNameDataContract.cs
- BaseUriHelper.cs
- ReaderWriterLockWrapper.cs
- safex509handles.cs
- Barrier.cs
- smtppermission.cs
- ImportOptions.cs
- JobInputBins.cs
- MultiSelectRootGridEntry.cs
- TableDetailsCollection.cs
- XmlBinaryReader.cs
- Brushes.cs
- SoapObjectInfo.cs
- IIS7UserPrincipal.cs
- ReadOnlyHierarchicalDataSource.cs
- MaterialCollection.cs
- ByteStorage.cs
- MessageQueueCriteria.cs
- SystemPens.cs
- _FixedSizeReader.cs
- Pointer.cs
- GridViewRowCollection.cs
- TypeNameHelper.cs
- DirectoryRootQuery.cs
- ScriptIgnoreAttribute.cs
- RecommendedAsConfigurableAttribute.cs
- UnsafeMethods.cs