Skip to content

WithCalledMethodExpression Code Mapping Condition

ldfallas edited this page Aug 31, 2015 · 3 revisions

Description

Tests conditions against the method reference expression of a method call expression.

This means that for a.Foo() the inner condicitions will be tested againt the a.Foo expression.

Properties

Property Usage Description
SubCondition Required/Content property The conditions to test on the left side of the invoked member owner.

Example

In this case we want to capture the left side of the expression being called. Here's an example of using this mapping action in conjuction with AssignName and WithLeftSideOfDottedAccess.

<?xml version="1.0" encoding="utf-8" ?>
<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.IO.IsolatedStorage.IsolatedStorageFile">
      <map:CodeMapPackage.Maps>
        ...
        <map:CodeMap Kind="Call" MemberName="OpenFile">
          <map:Conditional>
            <!-- Open file for read case  (discrimated by mode) -->
            <map:Case>
              <map:Case.Condition>
                <map:WithMethodCall>
                  <map:ArgumentCount>2</map:ArgumentCount>
                  <map:WithArgument Position="0">
                    <map:AssignName>$fileNameExpression</map:AssignName>
                  </map:WithArgument>
                  <map:WithArgument Position="1">
                    <map:Equals>FileMode.Open</map:Equals>
                  </map:WithArgument>
                  <map:WithCalledMethodExpression>
                    <map:WithLeftSideOfDottedAccess>
                      <map:AssignName>$folderReference</map:AssignName>
                    </map:WithLeftSideOfDottedAccess>
                  </map:WithCalledMethodExpression>
                </map:WithMethodCall>
              </map:Case.Condition>
              <map:Case.Action>
                <map:ReplaceWithTemplate>
                  await $folderReference.OpenStreamForReadAsync($fileNameExpression)
                </map:ReplaceWithTemplate>
              </map:Case.Action>
            </map:Case>
            ...
          </map:Conditional>
        </map:CodeMap>
      </map:CodeMapPackage.Maps>
       ...
    </map:CodeMapPackage>
  </MapUnit.Elements>
</MapUnit>

Notes

  • This condition succeeds if its inner conditions succeed.

Overview

Writing mappings

Code Mapping Actions

Code Mapping Conditions

XAML mapping actions

XAML mapping conditions

Misc

Clone this wiki locally