-
Notifications
You must be signed in to change notification settings - Fork 5
RedirectProperty Code Mapping Action
ldfallas edited this page Aug 31, 2015
·
3 revisions
<map:RedirectProperty NewPropertyOwner="NEW-PROPERTY-OWNER" NewProperty="NEW-PROPERTY-NAME"/>
Changes the reference to a property to be a reference to an inner property of the current expression.
This means that reference to A.B
will be changed to A.C.B
.
Property | Usage | Description |
---|---|---|
NewPropertyOwner | Required | The name of the inner property to reference |
NewProperty | Required | The name of the outer property to reference |
We want to convert from System.Device.Location.GeoCoordinate
to Windows.Devices.Geolocation.GeoPoint
. However when applying this conversion we need to change the way the Latitude property is reference.
We want to convert from this code:
-- Windows Phone 8 Silverlight --
public double RetrieveLatitude(GeoCoordinate c)
{
return c.Latitude;
}
To the following code:
public double RetrieveLatitude(Windows.Devices.Geolocation.Geopoint c)
{
return c.Position.Latitude;
}
We change use the RedirectProperty 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:CodeMap Kind="MemberAccess" MemberName="Latitude">
<map:RedirectProperty NewPropertyOwner="Position" NewProperty="Latitude"/>
</map:CodeMap>
<map:CodeMap Kind="MemberAccess" MemberName="Longitude">
<map:RedirectProperty NewPropertyOwner="Position" NewProperty="Longitude"/>
</map:CodeMap>
...
</map:CodeMapPackage.Maps>
</map:CodeMapPackage>
</MapUnit.Elements>
</MapUnit>
TODO
Contact us for more information
Overview
Writing mappings
Code Mapping Actions
- ActionSequence
- AddHelper
- AddNamespaceImport
- AddPreStatementFromTemplate
- CommentOut
- Conditional
- Keep Code Mapping Action
- MarkAsNotMapped
- RedirectCall
- RedirectCallToInnerMember
- RedirectIndexer
- RedirectProperty
- RemoveCurrentStatement
- RemoveParameter
- ReplaceClassUsage
- ReplaceMethodBodyWithTemplate
- ReplaceParameterDeclarationType
- ReplaceParameterMember
- ReplaceParameterValue
- ReplaceWithMethodCall
- ReplaceWithProperty
- ReplaceWithTemplate
Code Mapping Conditions
- AllConditionsApply
- ArgumentCount
- AssignName
- AssignNameToArgumentRange
- IsExpressionOfType
- IsStringLiteralMatchingRegex
- WithArgument
- WithAssignment
- WithAssignmentLeftSide
- WithAssignmentRightSide
- WithCalledMemberOwner
- WithCalledMethodExpression
- WithConstructorCall
- WithLambdaExpressionBody
- WithLambdaExpressionParameter
- WithLeftSideOfDottedAccess
- WithMemberInitValue
- WithMethodCall
XAML mapping actions
- ActionSequence
- AddStatementToConstructorFromTemplate
- BindPropertyValueElement Xaml mapping action
- ChangeEventHandlerEventArgsType
- CommentOutElement
- CommentOutProperty
- MarkAsNotMapped
- MoveValueToContentProperty
- RemoveNamespaceDeclaration
- RenameElement
- RenameProperty
- ReplaceAttributeValue
- ReplaceEventHandlerBodyWithTemplate
- ReplaceEventHandlerParameterMember
- ReplaceNamespaceDeclaration
- ReplacePropertyValueWithParentResource
- ReplaceStaticResourceWithThemeResource
- SetPropertyValueToComplexElement
- SetPropertyValueToSimpleValue
- WrapContent
XAML mapping conditions
Misc