-
Notifications
You must be signed in to change notification settings - Fork 5
WithCalledMemberOwner Code Mapping Condition
Tests conditions against the owner of a method being called.
This means that for a method call:
anInstance.foo();
The inner conditions of this element are tested against the anInstance
part of the expression.
Property | Usage | Description |
---|---|---|
SubCondition | Required/Content property | The conditions to test on the left side of the invoked member owner. |
The following example captures the variable holding a reference calls to Microsoft.Phone.Maps.Controls.Map.SetView
in order to transform them to calls to MapControl.TrySetView
.
<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.Maps.Controls.Map">
<map:CodeMapPackage.Maps>
...
<map:CodeMap Kind="Call" MemberName="SetView">
<map:Conditional>
<map:Case>
<map:Case.Condition>
<map:WithMethodCall>
<map:WithCalledMemberOwner>
<map:AssignName>$mapInstance</map:AssignName>
</map:WithCalledMemberOwner>
<map:WithArgument Position="0">
<map:AssignName>$arg0</map:AssignName>
</map:WithArgument>
<map:WithArgument Position="1">
<map:AssignName>$arg1</map:AssignName>
</map:WithArgument>
</map:WithMethodCall>
</map:Case.Condition>
<map:Case.Action>
<map:ReplaceWithTemplate>
await $mapInstance.TrySetViewAsync($arg0, $arg1)
</map:ReplaceWithTemplate>
</map:Case.Action>
</map:Case>
...
</map:Conditional>
</map:CodeMap>
...
</map:CodeMapPackage>
</MapUnit.Elements>
</MapUnit>
Given the following code:
--Windows Phone 8 Silverlight--
void SetMapView(Map aMap)
{
aMap.SetView(coordinate, 0.5);
}
We can apply this mapping and get the following code:
async void SetMapView(Windows.UI.Xaml.Controls.Maps.MapControl aMap)
{
await aMap.TrySetViewAsync(coordinate, 0.5);
}
The WithCalledMemberOwner
code action is used in this case to capture parts of a expression. The following picture shows how the different parts of the expression are captured.
- This condition succeeds if the current element is of the form a.foo().
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