[Test] public void GenericMethodWithParmsIsInvoked() { var member = new MemberName("genericmethodofsystemint32", "genericmethod", new[] { typeof(int)}); var method = MemberQuery.FindInstance(MemberQuery.FindMember, instance, new MemberSpecification(member, 1)); Assert.IsNotNull(method); var result = method.Invoke(new object[] {123}); Assert.AreEqual("sample123", result.Value.ToString()); }
void ExecuteOptionalMethod(MemberName theMethodName, Parse theCell) { try { Processor.Invoke(this, theMethodName, theCell); //todo: invokewiththrow? } catch (Exception e) { TestStatus.MarkException(theCell, e); } }
public TypedValue InvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters) { var type = Processor.ApplicationUnderTest.FindType("fit.Parse").Type; // lookup Fixture foreach (var member in FindMember(instance, memberName, type).Value) { return member.Invoke(new object[] { parameters.Value }); } // lookup FlowKeywords var runtimeType = Processor.ApplicationUnderTest.FindType("fit.Fixtures.FlowKeywords"); var runtimeMember = runtimeType.GetConstructor(2); var flowKeywords = runtimeMember.Invoke(new[] { instance.Value, Processor }); foreach (var member in FindMember(flowKeywords, memberName, type).Value) { return member.Invoke(new object[] { parameters.Value }); } return TypedValue.MakeInvalid(new MemberMissingException(instance.Type, memberName.Name, 1)); }
public TypedValue InvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters) { return keywords[memberName.Name](instance.GetValue<FlowInterpreter>(), parameters); }
public bool CanInvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters) { return keywords.ContainsKey(memberName.Name); }
static Maybe<RuntimeMember> FindMember(TypedValue flowKeywords, MemberName memberName, Type type) { return MemberQuery.FindDirectInstance(flowKeywords.Value, new MemberSpecification(memberName).WithParameterTypes(new[] {type})); }
public bool CanInvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters) { return true; }
public Maybe<RuntimeMember> FindStatic(MemberName memberName, Type[] parameterTypes) { return new MemberQuery( new MemberSpecification(memberName, parameterTypes.Length).WithParameterTypes(parameterTypes)) .StaticOnly() .FindMember(Type); }
public TypedValue InvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters) { return TypedValue.MakeInvalid(new MemberMissingException(instance.Type, memberName.Name, 1)); }
public MemberSpecification(MemberName memberName) { parameterCount = 0; this.memberName = memberName; }
public MemberSpecification(string memberName, int parameterCount) { this.parameterCount = parameterCount; this.memberName = new MemberName(memberName); }
public MemberSpecification(MemberName memberName, int parameterCount) { this.parameterCount = parameterCount; this.memberName = memberName; }
public TypedValue InvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters) { if (memberName.Name != "akeyword") return TypedValue.MakeInvalid(new ApplicationException("argh")); Field = "somevalue"; return TypedValue.Void; }