示例#1
0
 [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());
 }
示例#2
0
 void ExecuteOptionalMethod(MemberName theMethodName, Parse theCell) {
     try {
         Processor.Invoke(this, theMethodName, theCell); //todo: invokewiththrow?
     }
     catch (Exception e) { 
         TestStatus.MarkException(theCell, e);
     }
 }
示例#3
0
        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));
        }
示例#4
0
 public TypedValue InvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters)
 {
     return keywords[memberName.Name](instance.GetValue<FlowInterpreter>(), parameters);
 }
示例#5
0
 public bool CanInvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters)
 {
     return keywords.ContainsKey(memberName.Name);
 }
示例#6
0
 static Maybe<RuntimeMember> FindMember(TypedValue flowKeywords, MemberName memberName, Type type) {
     return MemberQuery.FindDirectInstance(flowKeywords.Value,
             new MemberSpecification(memberName).WithParameterTypes(new[] {type}));
 }
示例#7
0
 public bool CanInvokeSpecial(TypedValue instance, MemberName memberName, Tree<Cell> parameters) {
     return true;
 }
示例#8
0
 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));
 }
示例#10
0
 public MemberSpecification(MemberName memberName)
 {
     parameterCount = 0;
     this.memberName = memberName;
 }
示例#11
0
 public MemberSpecification(string memberName, int parameterCount)
 {
     this.parameterCount = parameterCount;
     this.memberName = new MemberName(memberName);
 }
示例#12
0
 public MemberSpecification(MemberName memberName, int parameterCount)
 {
     this.parameterCount = parameterCount;
     this.memberName = memberName;
 }
示例#13
0
 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;
 }