private MappingPair?GetMappingCallFromContext(InvocationExpressionSyntax invocation) { var info = _semanticModel.GetSymbolInfo(invocation); var method = info.Symbol as IMethodSymbol; if (method == null) { return(null); } var classType = method.ContainingType; if (!IsMapperType(classType)) { return(null); } if (method.Name != "Map") { return(null); } if (method.Arity != 1) { return(null); } if (method.TypeArguments.Length != 1) { return(null); } var argument = invocation .ArgumentList .Arguments .Single(); var argumentSymbolInformation = _semanticModel.GetSymbolInfo(argument.Expression); var sourceType = GetTypeFromSymbol(argumentSymbolInformation.Symbol); if (sourceType == null) { return(null); } var destinationType = method.ReturnType; var call = new MappingPair() { SourceType = sourceType, DestinationType = destinationType }; return(call); }
private MappingPair?GetConfigurationCallFromContext(InvocationExpressionSyntax invocation) { var info = _semanticModel.GetSymbolInfo(invocation); var method = info.Symbol as IMethodSymbol; if (method == null) { return(null); } if (!method.ContainingType.Equals(_configurationType)) { return(null); } if (method.Name != "CreateMap") { return(null); } if (method.TypeArguments.Length != 2) { return(null); } var sourceType = method .TypeArguments .FirstOrDefault(); var destinationType = method .TypeArguments .LastOrDefault(); var call = new MappingPair() { SourceType = sourceType, DestinationType = destinationType }; return(call); }