Ejemplo n.º 1
0
        private MvcControllerFunction RegisterController(Type controllerType, C1FunctionAttribute attribute, IEnumerable <ParameterProfile> functionParameters)
        {
            var controllerDescriptor = new ReflectedControllerDescriptor(controllerType);

            string @namespace  = String.IsNullOrEmpty(attribute.Namespace) ? controllerDescriptor.ControllerType.Namespace : attribute.Namespace;
            string name        = String.IsNullOrEmpty(attribute.Name) ? controllerDescriptor.ControllerName : attribute.Name;
            string description = attribute.Description ?? String.Empty;

            var function = new MvcControllerFunction(controllerDescriptor, @namespace, name, description, this);

            if (functionParameters != null)
            {
                foreach (var param in functionParameters)
                {
                    function.AddParameter(param);
                }
            }

            MvcFunctionRegistry.Functions.Add(function);

            return(function);
        }
Ejemplo n.º 2
0
        public MvcFunctionBuilder RegisterController(Type controllerType, string functionName = null, string description = null)
        {
            string @namespace = null, name = null;

            if (functionName != null)
            {
                ParseFunctionName(functionName, out @namespace, out name);
            }

            var attribute = new C1FunctionAttribute
            {
                Namespace   = @namespace,
                Name        = name,
                Description = description
            };

            var function = RegisterController(controllerType, attribute, new List <ParameterProfile>());

            MvcFunctionProvider.Reload();

            return(new MvcFunctionBuilder(function));
        }