Skip to content

ReplaceWithProperty Code Action

ldfallas edited this page Aug 31, 2015 · 4 revisions

Description

This mapping action is used to replace property usages with another property.

Properties

​Property ​Usage ​Description
​NewProperty ​Required ​The name of the property to replace the current one with.
NewPropertyOwner Optional The full name of the element that will be used as the owner of the property access. By using this property, the original owner expression will be removed.

Examples

Example 1

Say that we want to change uses of the ​Microsoft.Phone.Controls.Maps.MapControl.Children property to uses of the Windows.UI.Xaml.Controls.Maps.MapControl.MapElements property.

For example we have as input code:

     MapControl mapControl;
     ...
     return mapControl.Children.Count;

The mapper that implements this conversion looks like this:

<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.Phone.Controls.Maps.Map">
      <map:CodeMapPackage.Maps>
       <map:CodeMap Kind="MemberAccess" MemberName="Children">
           <map:ReplaceWithProperty NewProperty="MapElements"/>
        </map:CodeMap>
       </map:CodeMap>
       ...
      </map:CodeMapPackage.Maps>
    </map:CodeMapPackage>
  </MapUnit.Elements>
</MapUnit>

After applying this mapping on the previous code snippet, we get the following UWP code:

     Map mapControl;
     ...
     return mapControl.MapElements.Count;

Notes

  • If the NewPropertyOwner property is specified, the owner expression will be discarded

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally