Skip to content

ReplaceWithMethodCall Code Mapping Action

ldfallas edited this page Aug 31, 2015 · 3 revisions

Usage

<map:ReplaceWithMethodCall  MethodName="NEW-METHOD-NAME"/>

Description

This action replaces a member access of the form A.B with a A.Foo() expression.

This mapping action is us used to convert from a property to a getter method.

Properties

​Property ​Usage ​Description
MethodName Required The name of the getter method to generate

Example

The following mapping is going to convert from Microsoft.Devices.VibrateController.Default property to the Windows.Phone.Devices.Notification.VibrationDevice.GetDefault getter method We want to convert from:

-- Windows Phone 8 Silverlight --

var controller = Microsoft.Devices.VibrateController.Default;

To the following code:

-- Windows UWP --

var controller = Windows.Phone.Devices.Notification.VibrationDevice.GetDefault();
<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="Microsoft.Devices.VibrateController">
      <map:CodeMapPackage.Maps>

        <map:CodeMap Kind="Type">
          <map:ReplaceClassUsage NewNamespace="Windows.Phone.Devices.Notification"
                                 NewClassName="VibrationDevice" />
        </map:CodeMap>

        <map:CodeMap Kind="MemberAccess" MemberName="Default">
          <map:CodeMap.Action>
            <map:ReplaceWithMethodCall MethodName="GetDefault"/>
          </map:CodeMap.Action>
        </map:CodeMap>
         ...

      </map:CodeMapPackage.Maps>
    </map:CodeMapPackage>
  </MapUnit.Elements>
</MapUnit>

Notes

TODO

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally