-
Notifications
You must be signed in to change notification settings - Fork 5
Writing a mapping for interface implementations
There may be the case that an interface that exists in both the source and the target platform has some differences on its members.
For example the System.Windows.Data.IValueConverter
(https://msdn.microsoft.com/en-US/library/windows/apps/system.windows.data.ivalueconverter(v=vs.105).aspx) interface has different parameter types for Convert
and ConvertBack
methods in the UWP interface Windows.UI.Xaml.Data.IValueConverter
( https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.ivalueconverter ) .
For example:
object Convert(
object value,
Type targetType,
Object parameter,
CultureInfo culture
)
Equivalent UWP member:
object Convert(
object value,
Type targetType,
object parameter,
string language
)
The InterfaceImplementation
mapping kind is used to create a mapping for this scenario.
For example:
<map:CodeMapPackage Type="System.Windows.Data.IValueConverter">
<map:CodeMapPackage.Maps>
...
<map:CodeMap Kind="InterfaceImplementation">
<map:ActionSequence>
<map:ApplyToMethodDeclaration MethodName="Convert">
<map:ReplaceParameterDeclarationType Position="3">System.String</map:ReplaceParameterDeclarationType>
</map:ApplyToMethodDeclaration>
<map:ApplyToMethodDeclaration MethodName="ConvertBack">
<map:ReplaceParameterDeclarationType Position="3">System.String</map:ReplaceParameterDeclarationType>
</map:ApplyToMethodDeclaration>
</map:ActionSequence>
</map:CodeMap>
</map:CodeMapPackage.Maps>
</map:CodeMapPackage>
This mapping uses the [ApplyToMethodDeclaration Code Action](ApplyToMethodDeclaration Code Action) which applies a mapping action to a method declaration. The mapping action to be applied in this example is the ReplaceParameterDeclarationType Code Action . Also this example uses the [ActionSequence Code Action](ActionSequence Code Action) to change both the Convert
and the ConvertBack
method declarations.
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