Skip to content

ApplyToMethodDeclaration Code Mapping Action

ldfallas edited this page Nov 7, 2015 · 1 revision

Usage

<map:ApplyToMethodDeclaration MethodName="methodname">
    ... inner mapping action ...
</map:ApplyToMethodDeclaration>

Description

Applies a mapping actions to the specified method declaration.

This mapping action can be used with mapping of kind InterfaceImplementation or ClassInheritance.

Properties

​Property ​Usage ​Description
Action Content property Mapping action to apply to the method declaration
MethodName Required The name of the method to to apply the mapping action to

Example

The following example uses the ApplyToMethodDeclaration to apply the changes required to make a valid implementation of the IValueConverter interface. This interface changed in UWP.

<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="System.Windows.Data.IValueConverter">
      <map:CodeMapPackage.Maps>

        <map:CodeMap Kind="Type">
          <map:CodeMap.Action>
            <map:ReplaceClassUsage NewNamespace="Windows.UI.Xaml.Data"  NewClassName="IValueConverter" />
          </map:CodeMap.Action>
        </map:CodeMap>

        <map:CodeMap Kind="InterfaceImplementation">
          <map:ActionSequence>
            <map:ApplyToMethodDeclaration MethodName="Convert">
              <map:ReplaceParameterDeclarationType Position="3">System.String</map:ReplaceParameterDeclarationType>
            </map:ApplyToMethodDeclaration>
            <map:ApplyToMethodDeclaration MethodName="ConvertBack">
              <map:ReplaceParameterDeclarationType Position="3">System.String</map:ReplaceParameterDeclarationType>
            </map:ApplyToMethodDeclaration>
          </map:ActionSequence>
        </map:CodeMap>
      </map:CodeMapPackage.Maps>
    </map:CodeMapPackage>
  </MapUnit.Elements>
</MapUnit>

This mapping action change the signature of the Convert and ConvertBack methods.

Notes

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally