-
Notifications
You must be signed in to change notification settings - Fork 5
WritingCodeMappings
Mappings are used to specify the way a Windows Phone Silverlight API is converted to a Windows UWP API.
These mappings are specified for each source property, method, event or class to be converted to the target platform.
Code mappings are applied to C# source code. These mappings can be written using XAML files with .MAP extension. See Testing a mapping for more details on how to add a mapping to the conversion tool.
Here's an example of a basic map file.
<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="Windows.Phone.Speech.Recognition.SpeechRecognizerUISettings">
<map:CodeMapPackage.Maps>
<map:CodeMap Kind="Type">
<map:ReplaceClassUsage NewNamespace="Windows.Media.SpeechRecognition"
NewClassName="SpeechRecognizerUIOptions" />
</map:CodeMap>
<map:CodeMap Kind="MemberAccess" MemberName="ListenText">
<map:ReplaceWithProperty NewProperty="AudiblePrompt" />
</map:CodeMap>
<map:CodeMap Kind="MemberAccess" MemberName="ReadoutEnabled">
<map:ReplaceWithProperty NewProperty="IsReagdBackEnabled" />
</map:CodeMap>
</map:CodeMapPackage.Maps>
</map:CodeMapPackage>
</MapUnit.Elements>
</MapUnit>A mapping file contains a MapUnit. A map unit can have one or more CodeMapPackage.
A CodeMapPackage specify the operations uses of the members of one class. In the example above the CodeMapPackage is defined for the Windows.Phone.Speech.Recognition.SpeechRecognizerUISettings type . A CodeMapPackage contains a sequence of CodeMap elements.
The CodeMap element specify the way a member of the CodePackage class is converted to the target element. The 'Kind' property of the CodeMap element specify the kind of element this mapping will process. The following list enumerates the kinds of elements that can be processed:
| Kind | Description | More information / Examples |
|---|---|---|
| Assign | Acts on assignment expressions to the current member (ex. x.Prop = 1) |
WithAssignment |
| Call | Acts on method call expression for the current member (ex x.Foo() ) |
WithMethodCall |
| ElementAccess | Acts on indexer access expressions such as (ex. x.Foo["x"]) |
RedirectIndexer |
| EventDecl | Acts on event handlers for a given event of the current mapping class | Writing a mapping for event handlers |
| InterfaceImplementation | Acts on interface implementations of the current type (if it is an interface) | Writing a mapping for interface implementations |
| New | Acts on constructor invocations of the current type | WithConstructorCall |
| Type | Acts on type usages (variable declarations, fields , parameters, etc.) | ReplaceClassUsage |
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