Skip to content

ReplaceClassUsage Code Mapping Action

ldfallas edited this page Sep 11, 2015 · 4 revisions

Usage

<map:ReplaceClassUsage NewNamespace="NEW-NAMESPACE" NewClassName="NEW-CLASS-NAME" />

Also, for renames that include generic parameters:

<map:ReplaceClassUsage NewNamespace="NEW-NAMESPACE" NewClassName="NEW-CLASS-NAME" >
    <map:ReplaceClassUsage.NewTypeArguments>
      ...
      <map:TypeArgument>TYPE-ARGUMENT-NAME</map:TypeArgument>
      ...
    </map:ReplaceClassUsage.NewTypeArguments>
</map:ReplaceClassUsage>

Description

Replaces a class name reference with another class name.

Properties

​Property ​Usage ​Description
NewNamespace Required The namespace name of the target class
NewClassName Required The simple class name of the target class
NewTypeArguments Optional A list of type argument to generate for this type

Example

We want to convert from System.Device.Location.GeoCoordinate to Windows.Devices.Geolocation.GeoPoint .

We want to convert from this code:

-- Windows Phone 8 Silverlight --

public double RetrieveLatitude(GeoCoordinate c)
{
   ...
}

To the following code:

public double RetrieveLatitude(Windows.Devices.Geolocation.Geopoint c)
{
    ...
}

We change use the ReplaceClassUsage mapping action to perform this change:

<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.Device.Location.GeoCoordinate">
      <map:CodeMapPackage.Maps>
        <map:CodeMap Kind="Type">
          <map:CodeMap.Action>
            <map:ReplaceClassUsage NewNamespace="Windows.Devices.Geolocation" NewClassName="Geopoint" />
          </map:CodeMap.Action>
        </map:CodeMap>
         ...
      </map:CodeMapPackage.Maps>
    </map:CodeMapPackage>
  </MapUnit.Elements>
</MapUnit>

Notes

  • This mapping action can only be used in a CodeMap of kind Type

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally