-
Notifications
You must be signed in to change notification settings - Fork 5
WithLeftSideOfDottedAccess Code Mappings condition
Verifies that the current element is a member access (an expression of the form A.B).
Also it allows to test conditions on the left side of a A.B expression.
| Property | Usage | Description |
|---|---|---|
| SubConditions | Content property | Conditions to be tested with the left side of a A.B expression |
For this example we're going to use the WithLeftSideOfDottedAccess condition to capture the left side of uses of the Microsoft.Phone.Shell.IApplicationBar.IsVisibleproperty in order to convert them to an expression using the Windows.UI.Xaml.Controls.CommandBar.Visibility property.
Here's an example of the Microsoft.Phone.Shell.IApplicationBar.IsVisible in on a WP8 C# code.
public bool IsBarVisible(IApplicationBar bar)
{
return bar.IsVisible;
}We can write the mapping as follows:
<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.Shell.IApplicationBar">
<map:CodeMapPackage.Maps>
...
<map:CodeMap Kind="MemberAccess" MemberName="IsVisible">
<map:Conditional>
<map:Case>
<map:Case.Condition>
<map:WithLeftSideOfDottedAccess>
<map:AssignName>$owner</map:AssignName>
</map:WithLeftSideOfDottedAccess>
</map:Case.Condition>
<map:Case.Action>
<map:ReplaceWithTemplate>($owner.Visibility == Visibility.Visible) </map:ReplaceWithTemplate>
</map:Case.Action>
</map:Case>
<map:Default>
<map:Keep/>
</map:Default>
</map:Conditional>
</map:CodeMap>
...
</map:CodeMapPackage.Maps>
</map:CodeMapPackage>
</MapUnit.Elements>
</MapUnit>Once this mapping is applied the code the following code is generated:
public bool IsBarVisible(Windows.UI.Xaml.Controls.CommandBar bar)
{
return (bar.Visibility == Visibility.Visible);
}It is important to remark that this action changes the expression being tested for all its child conditions. This means that the map:AssignName specified as the inner condition will act on the left side of the expression. This effect is illustrated here:

- This code mapping condition will fail if the current element is not a A.B expression or if one of its inner conditions fails.
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