コード例 #1
0
 public void Registration_Suceeds_For_Well_Implemented_Aggregate_Function()
 {
     FunctionMap map = new FunctionMap();
     map.Register("test", typeof(TestFn<int>));
     Type t1 = typeof(TestFn<int>);
     Type t2 = map.GetTypeForFunction("test");
     Assert.AreEqual(typeof(TestFn<int>), map.GetTypeForFunction("test"));
 }
コード例 #2
0
        private AggregateFunctionContext CreateMemberContext(ClassMappingDescriptor descriptor, MemberMappingDescriptor member, FunctionMap functionMap)
        {
            Type   implementationType = functionMap.GetTypeForFunction(member.AggregateMappingDescription.FunctionName);
            string functionObjectName = string.Format("_{0}_to_{1}_Fn_",
                                                      member.AggregateMappingDescription.FunctionObject,
                                                      member.Member);

            if (implementationType.IsGenericType)
            {
                if (member.IsArray || member.IsList)
                {
                    Type instanceType = member.IsArray ?
                                        member.AggregateMappingDescription.TargetType.GetElementType() :
                                        member.AggregateMappingDescription.TargetType.GetGenericArguments()[0];
                    implementationType = implementationType.MakeGenericType(instanceType);
                }
                else
                {
                    implementationType = implementationType.MakeGenericType(member.AggregateMappingDescription.TargetType);
                }
            }

            IAggregateFunctionCodeGenerator generator = GetGeneratorImpl(implementationType, member);

            return(new AggregateFunctionContext(member,
                                                descriptor,
                                                implementationType,
                                                functionObjectName,
                                                generator));
        }
コード例 #3
0
        private AggregateFunctionContext CreateMemberContext(ClassMappingDescriptor descriptor, MemberMappingDescriptor member, FunctionMap functionMap)
        {
            Type implementationType = functionMap.GetTypeForFunction(member.AggregateMappingDescription.FunctionName);
            string functionObjectName = string.Format("_{0}_to_{1}_Fn_",
                member.AggregateMappingDescription.FunctionObject,
                member.Member);
            if (implementationType.IsGenericType)
            {
                if (member.IsArray || member.IsList)
                {
                    Type instanceType = member.IsArray ?
                        member.AggregateMappingDescription.TargetType.GetElementType() :
                        member.AggregateMappingDescription.TargetType.GetGenericArguments()[0];
                    implementationType = implementationType.MakeGenericType(instanceType);
                }
                else
                {
                    implementationType = implementationType.MakeGenericType(member.AggregateMappingDescription.TargetType);
                }
            }

            IAggregateFunctionCodeGenerator generator = GetGeneratorImpl(implementationType, member);

            return new AggregateFunctionContext(member,
                                descriptor,
                                implementationType,
                                functionObjectName,
                                generator);
        }
コード例 #4
0
 public void Retrieving_Unregistered_Function_Fails()
 {
     FunctionMap map = new FunctionMap();
     map.GetTypeForFunction("test");
 }