Exemplo n.º 1
0
 // Methods
 internal MappedFunction(MappedMetaModel model, FunctionMapping map, MethodInfo method)
 {
     this.model  = model;
     this.map    = map;
     this.method = method;
     rowTypes    = _emptyTypes;
     if ((map.Types.Count == 0) && (this.method.ReturnType == typeof(IMultipleResults)))
     {
         throw Error.NoResultTypesDeclaredForFunction(method.Name);
     }
     if ((map.Types.Count > 1) && (this.method.ReturnType != typeof(IMultipleResults)))
     {
         throw Error.TooManyResultTypesDeclaredForFunction(method.Name);
     }
     if ((map.Types.Count == 1) && (this.method.ReturnType != typeof(IMultipleResults)))
     {
         Type elementType = TypeSystem.GetElementType(method.ReturnType);
         var  list        = new List <MetaType>(1)
         {
             GetMetaType(map.Types[0], elementType)
         };
         rowTypes = list.AsReadOnly();
     }
     else if (map.Types.Count > 0)
     {
         var list2 = new List <MetaType>();
         foreach (TypeMapping mapping in map.Types)
         {
             Type type2 = model.FindType(mapping.Name);
             if (type2 == null)
             {
                 throw Error.CouldNotFindElementTypeInModel(mapping.Name);
             }
             MetaType metaType = this.GetMetaType(mapping, type2);
             if (!list2.Contains(metaType))
             {
                 list2.Add(metaType);
             }
         }
         this.rowTypes = list2.AsReadOnly();
     }
     else if (map.FunReturn != null)
     {
         this.returnParameter = new MappedReturnParameter(method.ReturnParameter, map.FunReturn);
     }
     ParameterInfo[] parameters = this.method.GetParameters();
     if (parameters.Length > 0)
     {
         var list3 = new List <MetaParameter>(parameters.Length);
         if (this.map.Parameters.Count != parameters.Length)
         {
             throw Error.IncorrectNumberOfParametersMappedForMethod(this.map.MethodName);
         }
         for (int i = 0; i < parameters.Length; i++)
         {
             list3.Add(new MappedParameter(parameters[i], this.map.Parameters[i]));
         }
         this.parameters = list3.AsReadOnly();
     }
     else
     {
         this.parameters = _emptyParameters;
     }
 }
Exemplo n.º 2
0
 // Methods
 internal MappedTable(MappedMetaModel model, TableMapping mapping, Type rowType)
 {
     this.model   = model;
     this.mapping = mapping;
     this.rowType = new MappedRootType(model, this, mapping.RowType, rowType);
 }