Exemple #1
0
        public Endpoint(ControllerActionDescriptor action)
        {
            var    elementGetterAttr           = action.GetElementGetterAttribute();
            bool   isElementGetter             = false;
            string getterParameterName         = null;
            string getterDisplayNameWhenLinked = null;

            if (elementGetterAttr != null)
            {
                isElementGetter             = true;
                getterDisplayNameWhenLinked = elementGetterAttr.DisplayNameWhenLinked;
                getterParameterName         = action.GetGetterParameterName();

                if (string.IsNullOrEmpty(getterParameterName))
                {
                    throw new Exception("Si el endpoint es un ElementGetter, entonces es obligatorio proporcionar un GetterParameterName NO NULO.");
                }
            }

            string              actionName     = CasingUtil.UpperCamelCaseToLowerUnderscore(action.ActionName);
            EndpointType        type           = EndpointType.Action;
            HttpMethodAttribute httpMethodAttr = action.GetHttpMethodAttribute();
            string              httpMethod     = action.GetHttpMethodValue();

            if (httpMethod == HttpMethods.Get)
            {
                type = EndpointType.Link;
            }

            var hateoasAttr = action.GetHateoasAttribute();

            this.Action = action;

            this.IsElementGetter     = isElementGetter;
            this.GetterParameterName = getterParameterName;

            this.DisplayNameWhenLinked = getterDisplayNameWhenLinked;
            this.ResourceCode          = hateoasAttr.ResourceCode;
            this.MvcActionName         = action.ActionName;
            this.EndpointName          = actionName;
            this.Type        = type;
            this.Scope       = hateoasAttr.Scope;
            this.UrlTemplate = httpMethodAttr.Template;
            this.HttpMethod  = httpMethod;
        }
Exemple #2
0
 public GetterAttribute(string displaynameWhenParent)
 {
     this.DisplayNameWhenLinked = CasingUtil.UpperCamelCaseToLowerUnderscore(displaynameWhenParent);
 }