コード例 #1
0
        public static void AddFunctions(this DbModel model, Type functionsType)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (functionsType == null)
            {
                throw new ArgumentNullException(nameof(functionsType));
            }

            functionsType
            .GetMethods(BindingFlags.Public | BindingFlags.InvokeMethod
                        | BindingFlags.Instance | BindingFlags.Static)
            .Select(methodInfo => new
            {
                MethodInfo        = methodInfo,
                FunctionAttribute = methodInfo.GetCustomAttribute <FunctionAttribute>()
            })
            .Where(method => method.FunctionAttribute != null)
            .ForEach(method => model.AddFunction(method.MethodInfo, method.FunctionAttribute));
        }