Ejemplo n.º 1
0
        private string CreateSource(Type type)
        {
            var builder = new SourceBuilder(type, Naming.MakeAccessorName(type));

            var no = 0;

            foreach (var method in type.GetMethods())
            {
                var attribute = method.GetCustomAttribute <MethodAttribute>(true);
                if (attribute == null)
                {
                    throw new AccessorGeneratorException($"Method is not supported for generation. type=[{type.FullName}], method=[{method.Name}]");
                }

                var nodes   = attribute.GetNodes(sqlLoader, option, method);
                var visitor = new ParameterResolveVisitor(method);
                visitor.Visit(nodes);
                var methodMetadata = new MethodMetadata(
                    no,
                    method,
                    attribute.CommandType,
                    attribute.MethodType,
                    (attribute as IReturnValueBehavior)?.ReturnValueAsResult ?? false,
                    nodes,
                    visitor.Parameters,
                    visitor.DynamicParameters);
                builder.AddMethod(methodMetadata);

                no++;
            }

            return(builder.Build());
        }