Skip to content

ActionSequence Code Action

ldfallas edited this page Aug 31, 2015 · 3 revisions

Description

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>

Examples

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();
    }
}

Notes

  • Actions are executed from top to bottom

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally