Exemple #1
0
        private static ContractResultPredicateArgument TryCreateContractResultArgument(
            ICSharpExpression expression)
        {
            // Specified expression could have Contract.Result as an inner expression,
            // like Contract.Result<string>().Length
            // Let's try to find it out there.
            var contractResultReference =
                expression.ProcessRecursively <IInvocationExpression>()
                .Select(ExtractContractResultReference)
                .FirstOrDefault();

            if (contractResultReference == null)
            {
                return(null);
            }

            return(contractResultReference
                   .With(x => x.TypeArguments.FirstOrDefault())
                   .With(x => x as IDeclaredType)
                   .Return(x => new ContractResultPredicateArgument(x, contractResultReference)));
        }