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
- XmlDocumentSerializer.cs
- MessageQueueConverter.cs
- DesignerView.cs
- Exceptions.cs
- InputGestureCollection.cs
- BamlReader.cs
- SystemBrushes.cs
- XmlIlVisitor.cs
- BitmapInitialize.cs
- ChildTable.cs
- TypefaceMetricsCache.cs
- InkPresenterAutomationPeer.cs
- EventSinkHelperWriter.cs
- StringStorage.cs
- PngBitmapDecoder.cs
- UriWriter.cs
- QilFunction.cs
- TextEncodedRawTextWriter.cs
- FontUnitConverter.cs
- FamilyMap.cs
- MultipleViewPattern.cs
- ObjectManager.cs
- _RequestLifetimeSetter.cs
- ISAPIWorkerRequest.cs
- ClrProviderManifest.cs
- EntityContainerEmitter.cs
- XmlCDATASection.cs
- GPRECT.cs
- RegistrySecurity.cs
- webeventbuffer.cs
- ProtocolsConfigurationHandler.cs
- ArgIterator.cs
- LabelExpression.cs
- DeferredTextReference.cs
- ServiceParser.cs
- GenericUriParser.cs
- OutputCacheSettings.cs
- TextBoxBase.cs
- TextEditor.cs
- ApplicationTrust.cs
- BatchServiceHost.cs
- FixedSOMPageElement.cs
- Visual3D.cs
- PagesChangedEventArgs.cs
- StylusPointPropertyId.cs
- BaseWebProxyFinder.cs
- AutoFocusStyle.xaml.cs
- XmlSchemaGroupRef.cs
- DependencyProperty.cs
- ConnectionManagementElement.cs
- Regex.cs
- FirstMatchCodeGroup.cs
- SourceFileInfo.cs
- Bind.cs
- DeclaredTypeValidatorAttribute.cs
- ParameterCollection.cs
- ServiceDocumentFormatter.cs
- EtwProvider.cs
- DataContract.cs
- ThaiBuddhistCalendar.cs
- BinaryObjectReader.cs
- DataObjectFieldAttribute.cs
- XmlSchemaAll.cs
- FlowNode.cs
- SynchronizedPool.cs
- Set.cs
- OleDbConnectionFactory.cs
- VSWCFServiceContractGenerator.cs
- HandledEventArgs.cs
- Array.cs
- EventPropertyMap.cs
- Message.cs
- WorkflowTransactionService.cs
- SHA256.cs
- MobileTemplatedControlDesigner.cs
- UIAgentRequest.cs
- UdpUtility.cs
- PeerPresenceInfo.cs
- RenderingBiasValidation.cs
- TemplateControlBuildProvider.cs
- EmbossBitmapEffect.cs
- SQlBooleanStorage.cs
- PolyBezierSegment.cs
- VerbConverter.cs
- NotCondition.cs
- Version.cs
- DynamicResourceExtensionConverter.cs
- X509CertificateInitiatorClientCredential.cs
- Documentation.cs
- GridViewColumnCollection.cs
- RichTextBoxDesigner.cs
- XomlCompiler.cs
- SourceItem.cs
- WmlCommandAdapter.cs
- ClaimSet.cs
- TextParagraphView.cs
- LayoutDump.cs
- CqlLexer.cs
- IIS7WorkerRequest.cs
- TimeSpan.cs