-
Notifications
You must be signed in to change notification settings - Fork 5
ActionSequence Code Action
ldfallas edited this page Aug 31, 2015
·
3 revisions
This code mapping action is used to apply several mapping actions to the current element.
This elements acts as a container of several mapping actions.
Usage
<map:ActionSequence>
... Mapping Actions ...
</map:ActionSequence>
Input source code:
public class MyClass
{
public void MyMethod()
{
MyNamespace.MyClassToBeConverted x = new MyNamespace.MyClassToBeConverted();
x.Print();
}
}
For this example we want to convert call to method MyNamespace.MyClassToBeConverted.MethodToBeConverted
to calls to MyNewMethod
. Also we want to include a call to System.Diagnostics.Debug.WriteLine
as the previous statement.
We can use the ActionSequence
action to do this as follows:
<MapUnit xmlns="clr-namespace:Mobilize.Mappers.Extensibility.Core;assembly=Mobilize.ExtensibleMappers"
xmlns:map="clr-namespace:Mobilize.Mappers.Extensibility.Code;assembly=Mobilize.ExtensibleMappers">
<MapUnit.Elements>
<map:CodeMapPackage Type="MyNamespace.MyClassToBeConverted">
<map:CodeMapPackage.Maps>
<map:CodeMap Kind="Call" MemberName="Print" >
<map:ActionSequence>
<map:AddPreStatementFromTemplate>
System.Diagnostics.Debug.WriteLine("About to call 'Write'");
</map:AddPreStatementFromTemplate>
<map:RedirectCall NewMethod="Write" />
</map:ActionSequence>
</map:CodeMap>
</map:CodeMapPackage.Maps>
</map:CodeMapPackage>
</MapUnit.Elements>
</MapUnit>
The result of applying this mapping on the C# snippet above is the following:
public class MyClass
{
public void MyMethod()
{
MyNamespace.MyClassToBeConverted x = new MyNamespace.MyClassToBeConverted();
System.Diagnostics.Debug.WriteLine("About to call 'Write'");
x.Write();
}
}
- Actions are executed from top to bottom
Contact us for more information
Overview
Writing mappings
Code Mapping Actions
- ActionSequence
- AddHelper
- AddNamespaceImport
- AddPreStatementFromTemplate
- CommentOut
- Conditional
- Keep Code Mapping Action
- MarkAsNotMapped
- RedirectCall
- RedirectCallToInnerMember
- RedirectIndexer
- RedirectProperty
- RemoveCurrentStatement
- RemoveParameter
- ReplaceClassUsage
- ReplaceMethodBodyWithTemplate
- ReplaceParameterDeclarationType
- ReplaceParameterMember
- ReplaceParameterValue
- ReplaceWithMethodCall
- ReplaceWithProperty
- ReplaceWithTemplate
Code Mapping Conditions
- AllConditionsApply
- ArgumentCount
- AssignName
- AssignNameToArgumentRange
- IsExpressionOfType
- IsStringLiteralMatchingRegex
- WithArgument
- WithAssignment
- WithAssignmentLeftSide
- WithAssignmentRightSide
- WithCalledMemberOwner
- WithCalledMethodExpression
- WithConstructorCall
- WithLambdaExpressionBody
- WithLambdaExpressionParameter
- WithLeftSideOfDottedAccess
- WithMemberInitValue
- WithMethodCall
XAML mapping actions
- ActionSequence
- AddStatementToConstructorFromTemplate
- BindPropertyValueElement Xaml mapping action
- ChangeEventHandlerEventArgsType
- CommentOutElement
- CommentOutProperty
- MarkAsNotMapped
- MoveValueToContentProperty
- RemoveNamespaceDeclaration
- RenameElement
- RenameProperty
- ReplaceAttributeValue
- ReplaceEventHandlerBodyWithTemplate
- ReplaceEventHandlerParameterMember
- ReplaceNamespaceDeclaration
- ReplacePropertyValueWithParentResource
- ReplaceStaticResourceWithThemeResource
- SetPropertyValueToComplexElement
- SetPropertyValueToSimpleValue
- WrapContent
XAML mapping conditions
Misc