public static DataContextMapping <TContxt> Function <TContxt>(this DataContextMapping <TContxt> contextMapping, Expression <Func <TContxt, object> > predicate, FunctionAttribute function) where TContxt : DataContext { var mi = GetMember(predicate); return(Function(contextMapping, mi, function)); }
static DataContextMapping <TContxt> Function <TContxt>(this DataContextMapping <TContxt> contextMapping, MemberInfo mi, FunctionAttribute function) where TContxt : DataContext { if (mi.DeclaringType != typeof(TContxt)) { throw Error.MappedMemberHadNoCorrespondingMemberInType(mi.Name, typeof(TContxt).Name); } contextMapping.Add(mi, function); return(contextMapping); }
public static FunctionAttribute Name(this FunctionAttribute function, string name) { function.Name = name; return(function); }
public static FunctionAttribute Composable(this FunctionAttribute function) { function.IsComposable = true; return(function); }
// Methods public AttributedMetaFunction(AttributedMetaModel model, MethodInfo mi, IAttributeProvider attributeProvider) { if (model == null) { throw Error.ArgumentNull("model"); } if (mi == null) { throw Error.ArgumentNull("mi"); } if (attributeProvider == null) { throw Error.ArgumentNull("attributeProvider"); } this.attributeProvider = attributeProvider; this.model = model; this.methodInfo = mi; this.rowTypes = _emptyTypes; //this.functionAttrib = Attribute.GetCustomAttribute(mi, typeof(FunctionAttribute), false) as FunctionAttribute; this.functionAttrib = this.attributeProvider.GetFunction(mi); //(ResultTypeAttribute[])Attribute.GetCustomAttributes(mi, typeof(ResultTypeAttribute)); var resultTypeAttributes = attributeProvider.GetResultTypeAttributes(mi); if (resultTypeAttributes != null && resultTypeAttributes.Length == 0 && mi.ReturnType == typeof(IMultipleResults)) { throw Mapping.Error.NoResultTypesDeclaredForFunction(mi.Name); } if (resultTypeAttributes != null && resultTypeAttributes.Length > 1 && mi.ReturnType != typeof(IMultipleResults)) { throw Mapping.Error.TooManyResultTypesDeclaredForFunction(mi.Name); } if (((resultTypeAttributes != null && resultTypeAttributes.Length <= 1) && mi.ReturnType.IsGenericType) && (((mi.ReturnType.GetGenericTypeDefinition() == typeof(IEnumerable <>)) || (mi.ReturnType.GetGenericTypeDefinition() == typeof(ISingleResult <>))) || (mi.ReturnType.GetGenericTypeDefinition() == typeof(IQueryable <>)))) { Type elementType = TypeSystem.GetElementType(mi.ReturnType); var list = new List <MetaType>(1); list.Add(this.GetMetaType(elementType)); this.rowTypes = list.AsReadOnly(); } else if (resultTypeAttributes != null && resultTypeAttributes.Length > 0) { var list2 = new List <MetaType>(); foreach (ResultTypeAttribute attribute in resultTypeAttributes) { Type type = attribute.Type; MetaType metaType = this.GetMetaType(type); if (!list2.Contains(metaType)) { list2.Add(metaType); } } this.rowTypes = list2.AsReadOnly(); } else { this.returnParameter = new AttributedMetaParameter(this.methodInfo.ReturnParameter); } ParameterInfo[] parameters = mi.GetParameters(); if (parameters.Length > 0) { var list3 = new List <MetaParameter>(parameters.Length); int index = 0; int length = parameters.Length; while (index < length) { var item = new AttributedMetaParameter(parameters[index]); list3.Add(item); index++; } this.parameters = list3.AsReadOnly(); } else { this.parameters = _emptyParameters; } }
public void Add(MemberInfo mi, FunctionAttribute function, ResultTypeAttribute[] resultTypes) { functions[mi] = function; this.resultTypeAttributes[mi] = resultTypes; }
public void Add(MemberInfo mi, FunctionAttribute function) { functions[mi] = function; }