-
Notifications
You must be signed in to change notification settings - Fork 5
ReplaceWithProperty Code Action
ldfallas edited this page Aug 31, 2015
·
4 revisions
This mapping action is used to replace property usages with another property.
| Property | Usage | Description |
|---|---|---|
| NewProperty | Required | The name of the property to replace the current one with. |
| NewPropertyOwner | Optional | The full name of the element that will be used as the owner of the property access. By using this property, the original owner expression will be removed. |
Say that we want to change uses of the Microsoft.Phone.Controls.Maps.MapControl.Children property to uses of the Windows.UI.Xaml.Controls.Maps.MapControl.MapElements property.
For example we have as input code:
MapControl mapControl;
...
return mapControl.Children.Count;The mapper that implements this conversion looks like this:
<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.Controls.Maps.Map">
<map:CodeMapPackage.Maps>
<map:CodeMap Kind="MemberAccess" MemberName="Children">
<map:ReplaceWithProperty NewProperty="MapElements"/>
</map:CodeMap>
</map:CodeMap>
...
</map:CodeMapPackage.Maps>
</map:CodeMapPackage>
</MapUnit.Elements>
</MapUnit>After applying this mapping on the previous code snippet, we get the following UWP code:
Map mapControl;
...
return mapControl.MapElements.Count;- If the
NewPropertyOwnerproperty is specified, theownerexpression will be discarded
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