-
Notifications
You must be signed in to change notification settings - Fork 5
AddHelper Code Action
ldfallas edited this page Aug 17, 2015
·
2 revisions
Adds a file to the target project. This file may contain the implementation of a functionality that is missing in the target platform.
| Property | Usage | Description |
|---|---|---|
| Path | Required / Content property | The path to the helper file to be included |
Since the Microsoft.Phone.Tasks.WebBrowserTask class is not available in UWP. We are going to create a small helper class which contains the same functionality exposing the same API.
--Windows Phone 8 Silverlight--
...
var task = new WebBrowserTask();
task.Uri = new Uri("http://localhost/");
task.Show();
...We are going to define a helper class as followings:
-- Conversion tool helper --
/// WebBrowserTaskHelper.cs
namespace WindowsPhoneUWP.UpgradeHelpers {
class WebBrowserTaskHelper
{
public Uri Uri { get; internal set; }
internal WebBrowserTaskHelper()
{
}
internal void Show()
{
Windows.System.Launcher.LaunchUriAsync(Uri);
}
}
}Now to create a mapping that will include this helper class we can write the following:
<map:CodeMapPackage Type="Microsoft.Phone.Tasks.WebBrowserTask">
<map:ActionSequence>
<map:AddHelper Path="..\Helpers\WebBrowserTaskHelper.cs" />
<map:ReplaceClassUsage NewNamespace="WindowsPhoneUWP.UpgradeHelpers" NewClassName="WebBrowserTaskHelper" />
</map:ActionSequence>
</map:CodeMap>By executing this mapping we get the following code:
var task = new WindowsPhoneUWP.UpgradeHelpers.WebBrowserTaskHelper();
task.Uri = new Uri("http://localhost/");
task.Show();- The path of the helper file is relative to the root of the mappings folder.
- The file in the target project is generated in a directory called
Helper
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