-
Notifications
You must be signed in to change notification settings - Fork 5
ReplaceParameterDeclarationType Code Action
ldfallas edited this page Aug 31, 2015
·
3 revisions
<map:ReplaceParameterDeclarationType Position="PARAMETER-POSITION">
C#-CLASS-NAME
</map:ReplaceParameterDeclarationType>
This code mapping action changes the declaration of the current event handler by replacing the type of the parameter specified by the Position
property.
This mapping action can only be used as part of a EventDecl
code mapping.
Property | Usage | Description |
---|---|---|
Position | Required | A zero-based index indicating the parameter to change the type to |
NewTypeName | Required / Content property | The full name of the type to replace current parameter declaration |
We want to write a mapping that converts the event handlers of the System.Windows.Controls.Slider.ValueChanged
event to its UWP equivalent.
--Windows Phone 8 Silverlight--
void RegisterHandler()
{
aSlider.ValueChanged += aSlider_ValueChanged;
}
void aSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
valueToStore = e.NewValue;
}
We want to convert this:
-- Windows UWP --
void Moo()
{
aSlider.ValueChanged += aSlider_ValueChanged;
}
void aSlider_ValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
{
valueToStore = e.NewValue;
}
In order to change the parameter type of the event handler we can write the following mapping:
<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.Controls.Slider">
<map:CodeMapPackage.Maps>
...
<map:CodeMap Kind="EventDecl" MemberName="ValueChanged">
<map:CodeMap.Action>
<map:ReplaceParameterDeclarationType Position="1">
Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs
</map:ReplaceParameterDeclarationType>
</map:CodeMap.Action>
</map:CodeMap>
...
</map:CodeMapPackage.Maps>
</map:CodeMapPackage>
</MapUnit.Elements>
</MapUnit>
- This mapping action only a applies to
CodeMap
s of kindEventDecl
.
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