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
- ResourcesChangeInfo.cs
- ADConnectionHelper.cs
- PluralizationService.cs
- HtmlTableRow.cs
- ResourcesChangeInfo.cs
- ClientType.cs
- SafeProcessHandle.cs
- NameValueCollection.cs
- XPathCompileException.cs
- UnsafeCollabNativeMethods.cs
- SkewTransform.cs
- ScriptControlManager.cs
- followingsibling.cs
- GridItem.cs
- Registry.cs
- ListInitExpression.cs
- ApplicationContext.cs
- XPathEmptyIterator.cs
- DesignParameter.cs
- BaseTemplateParser.cs
- OuterGlowBitmapEffect.cs
- DataTransferEventArgs.cs
- BounceEase.cs
- ObjectAssociationEndMapping.cs
- FieldCollectionEditor.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- SafeHandle.cs
- Ipv6Element.cs
- FlowDocumentView.cs
- StrictAndMessageFilter.cs
- IconConverter.cs
- SignatureToken.cs
- RadioButton.cs
- TextFindEngine.cs
- DataGridViewCellStyleChangedEventArgs.cs
- CipherData.cs
- WpfKnownMemberInvoker.cs
- LabelDesigner.cs
- RepeatEnumerable.cs
- GridItemCollection.cs
- CompilationPass2Task.cs
- ParseNumbers.cs
- RequiredAttributeAttribute.cs
- ToolStripGripRenderEventArgs.cs
- CodeDOMUtility.cs
- ParserStack.cs
- XmlBinaryReader.cs
- InterleavedZipPartStream.cs
- SplineQuaternionKeyFrame.cs
- Flowchart.cs
- MSG.cs
- FixUpCollection.cs
- Baml2006ReaderSettings.cs
- DataSourceXmlAttributeAttribute.cs
- PrintController.cs
- DbgCompiler.cs
- RenderData.cs
- SwitchElementsCollection.cs
- ObjectParameterCollection.cs
- ReflectPropertyDescriptor.cs
- updatecommandorderer.cs
- ErrorTolerantObjectWriter.cs
- TreeNodeEventArgs.cs
- ListItemCollection.cs
- RuntimeHelpers.cs
- UnmanagedMemoryStream.cs
- TextDecoration.cs
- SizeChangedInfo.cs
- ColumnResult.cs
- CapabilitiesUse.cs
- BackgroundWorker.cs
- BitmapEffectCollection.cs
- TextMetrics.cs
- WmlPanelAdapter.cs
- WebResponse.cs
- QueryCreatedEventArgs.cs
- BindableAttribute.cs
- FactoryGenerator.cs
- BamlStream.cs
- PointLightBase.cs
- StrongBox.cs
- _IPv4Address.cs
- WebServiceMethodData.cs
- ProviderSettingsCollection.cs
- CommentAction.cs
- RadioButtonStandardAdapter.cs
- GorillaCodec.cs
- EventLogException.cs
- XmlSchemaAny.cs
- KeyedCollection.cs
- ParserStreamGeometryContext.cs
- SchemaNotation.cs
- TextTrailingCharacterEllipsis.cs
- InfocardExtendedInformationCollection.cs
- HttpChannelHelper.cs
- JsonFormatWriterGenerator.cs
- TypeSystemHelpers.cs
- ReplyAdapterChannelListener.cs
- DataControlImageButton.cs
- RelationshipDetailsRow.cs