public void MethodCallResolver_WithRequest_ReturnsNotNull() { var resolver = new MethodCallResolver <EmptyCtorClass>(r => new EmptyCtorClass()); var result = resolver.Resolve(new Request(typeof(IEmptyClass))); Assert.IsTrue(result is EmptyCtorClass); }
private IAstMethodReference ResolveOperatorAsMethod(BinaryExpression binary) { var operatorName = NameMap[binary.Operator.Name]; var resolved = (IAstMethodReference)OperatorsType.ResolveMember(operatorName); if (resolved == null) { throw new NotImplementedException("ResolveOperatorReferences: Failed to resolve operator '" + binary.Operator.Name + "' (" + operatorName + ")."); } return(methodCallResolver.Resolve(resolved, OperatorsType, new[] { binary.Left, binary.Right })); }
private IAstMethodReference Resolve(string name, object target, params object[] arguments) { var resolver = new MethodCallResolver(new GenericTypeHelper()); var methods = typeof(TestClass).GetMethods().Where(m => m.Name == name); var reflector = new Reflector(); var result = resolver.Resolve( new AstMethodGroup(name, methods.Select(m => new AstReflectedMethod(m, reflector)).ToArray()), target != null ? (IAstElement) new PrimitiveValue(target) : new AstReflectedType(typeof(TestClass), reflector), arguments.Select(a => (a as IAstExpression) ?? new PrimitiveValue(a)).ToArray() ); return(result); }