-
Notifications
You must be signed in to change notification settings - Fork 5
WithConstructorCall Code Mapping Condition
ldfallas edited this page Aug 31, 2015
·
3 revisions
<map:WithConstructorCall>
...mapping conditions....
</map:WithConstructorCall>
Allows testing conditions on constructor calls.
Property | Usage | Description |
---|---|---|
SubConditions | Content property | Conditions to be tested with the left side of a A.B expression |
For example we want to transform the following WP8 expression:
--Windows Phone 8 Silverlight--
void DoCall()
{
new PhoneCallTask()
{
DisplayName = "The display name",
PhoneNumber = GetPhoneNumber()
}.Show();
}
To the following UWP expression :
void DoCall()
{
Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI(GetPhoneNumber(), "The display name");
}
We can use the WithConstructorCall
mapping action to identify the constructor call in the left side of the Show
method reference.
<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.Tasks.PhoneCallTask">
<map:CodeMapPackage.Maps>
<map:CodeMap Kind="Call" MemberName="Show">
<map:Conditional>
<map:Case>
<map:Case.Condition>
<map:WithCalledMemberOwner>
<map:WithConstructorCall>
<map:WithMemberInitValue MemberName="PhoneNumber">
<map:AssignName>$phoneNumber</map:AssignName>
</map:WithMemberInitValue>
<map:WithMemberInitValue MemberName="DisplayName">
<map:AssignName>$displayName</map:AssignName>
</map:WithMemberInitValue>
</map:WithConstructorCall>
</map:WithCalledMemberOwner>
</map:Case.Condition>
<map:Case.Action>
<map:ReplaceWithTemplate>
Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI($phoneNumber, $displayName)
</map:ReplaceWithTemplate>
</map:Case.Action>
</map:Case>
...
</map:Conditional>
</map:CodeMap>
</map:CodeMapPackage.Maps>
</map:CodeMapPackage>
</MapUnit.Elements>
</MapUnit>
Using the WithConstructorCall
condition is going to filter out all expressions that doesn't have a constructor call on the left side of the Show
reference.
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