将prioject转换为VB.NET后出错(来自C#)

时间:2014-03-25 15:32:08

标签: c# vb.net converter automapper

我想将这个C#转换为VB.NET

internal static void CreateMap(AutoMapperService autoMapperService)
    {
        Player.CreateMap(autoMapperService);
        RawStats.CreateMap(autoMapperService);

        autoMapperService.CreateMap<string, GameTypeEnum>()
            .ConvertUsing(s => GameTypeConsts.GameTypes
                .First(x => x.Value == s).Key);

        autoMapperService.CreateMap<string, GameModeEnum>()
            .ConvertUsing(s => GameModeConsts.GameModes
                .First(x => x.Value == s).Key);

        autoMapperService.CreateMap<string, GameSubTypeEnum>()
            .ConvertUsing(s => GameSubTypeConsts.GameSubTypes
                .First(x => x.Value == s).Key);

        CreateMap<Game>(autoMapperService);
        CreateMap<IGame>(autoMapperService).As<Game>();

        autoMapperService.CreateMap<RecentGamesDto, IEnumerable<IGame>>()
            .ConvertUsing(x => x.Games.Select(autoMapperService.Map<GameDto, IGame>));
    }

VB.NET:

 Friend Shared Sub CreateMap(autoMapperService As AutoMapperService)
        Player.CreateMap(autoMapperService)
        RawStats.CreateMap(autoMapperService)

        autoMapperService.CreateMap(Of String, GameTypeEnum).ConvertUsing(Function(s) GameTypeConsts.GameTypes.First(Function(x) x.Value = s).Key)

        autoMapperService.CreateMap(Of String, GameModeEnum).ConvertUsing(Function(s) GameModeConsts.GameModes.First(Function(x) x.Value = s).Key)

        autoMapperService.CreateMap(Of String, GameSubTypeEnum).ConvertUsing(Function(s) GameSubTypeConsts.GameSubTypes.First(Function(x) x.Value = s).Key)

        CreateMap(Of Game)(autoMapperService)
        CreateMap(Of IGame)(autoMapperService).[As](Of Game)()

        autoMapperService.CreateMap(Of RecentGamesDto, IEnumerable(Of IGame))().ConvertUsing(Function(x) x.Games.Select(autoMapperService.Map(Of GameDto, IGame)))
    End Sub

我在最后一个VB.NET Codeline上获得异常: enter image description here 告诉我,我错过了物品属性

原来的项目: https://github.com/XeeX/LeagueOfLegendsAPI 这是我缺少item属性的函数: https://github.com/XeeX/LeagueOfLegendsAPI/blob/master/PortableLeagueApi.Core/Services/AutoMapperService.cs

有人能给我一个提示我缺少什么吗?

此致

1 个答案:

答案 0 :(得分:1)

我不是100%肯定(我的VB.NET技能已经生锈),但我认为问题在于你是如何尝试将Map方法作为参数传递给{{ 1}}方法。尝试使用AddressOf

Select