-
Notifications
You must be signed in to change notification settings - Fork 5
IsExpressionOfType Code Mapping Condition
ldfallas edited this page Aug 31, 2015
·
3 revisions
This condition succeeds if the full name of the type of the current expression is the same as the specified in the Type
property.
Property | Usage | Description |
---|---|---|
Type | Required | The full name of the type to check |
For example we want to convert from System.Windows.Documents.InlineCollection.Add for the case when the argument is a string. In this case we need to create a Windows.UI.Xaml.Documents.Run.
The important thing here is that we need to do this only when the argument is of type System.String
. In other cases we will leave it as the original expression.
We can write:
<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="System.Windows.Documents.InlineCollection">
<map:CodeMapPackage.Maps>
<map:CodeMap Kind="Type">
<map:CodeMap.Action>
<map:ReplaceClassUsage NewNamespace="Windows.UI.Xaml.Documents"
NewClassName="InlineCollection" />
</map:CodeMap.Action>
</map:CodeMap>
<map:CodeMap Kind="Call" MemberName="Add">
<map:Conditional>
<map:Case>
<map:Case.Condition>
<map:WithMethodCall>
<map:WithCalledMemberOwner>
<map:AssignName>$owner</map:AssignName>
</map:WithCalledMemberOwner>
<map:ArgumentCount>1</map:ArgumentCount>
<map:WithArgument Position="0">
<map:IsExpressionOfType>System.String</map:IsExpressionOfType>
<map:AssignName>$param</map:AssignName>
</map:WithArgument>
</map:WithMethodCall>
</map:Case.Condition>
<map:Case.Action>
<map:ReplaceWithTemplate>
$owner.Add(new Windows.UI.Xaml.Documents.Run() { Text = $param })
</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>
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