/// <summary>
        /// Reads from HTTP Message
        /// </summary>
        /// <param name="type"></param>
        /// <param name="readStream"></param>
        /// <param name="content"></param>
        /// <param name="formatterLogger"></param>
        /// <returns></returns>
        public override object ReadFromStream(Type type, System.IO.Stream readStream, System.Net.Http.HttpContent content, IFormatterLogger formatterLogger)
        {
            OAuthROCRequest        result = null;
            Task <OAuthROCRequest> task   = null;

            switch (content.Headers.ContentType.MediaType)
            {
            case "application/x-www-form-urlencoded":
                task = ReadForm(content);
                break;

            case "application/json":
                task = ReadJson(content);
                break;

            case "application/xml":
                task = ReadXml(content);
                break;
            }

            if (task != null)
            {
                task.Wait();
                if (task.IsFaulted)
                {
                    throw task.Exception;
                }
                result = task.Result;
            }

            return(result);
        }
 public bool BindModel(System.Web.Http.Controllers.HttpActionContext actionContext, ModelBindingContext bindingContext)
 {
     var value = new OAuthROCRequest
     {
         GrantType = GetValue(bindingContext, "grant_type"),
         Username = GetValue(bindingContext, "username"),
         Password = GetValue(bindingContext, "password"),
         Scope = GetValue(bindingContext, "scope")
     };
     actionContext.ActionArguments[bindingContext.ModelName] = value;
     return true;
 }
Exemplo n.º 3
0
        public bool BindModel(System.Web.Http.Controllers.HttpActionContext actionContext, ModelBindingContext bindingContext)
        {
            var value = new OAuthROCRequest
            {
                GrantType = GetValue(bindingContext, "grant_type"),
                Username  = GetValue(bindingContext, "username"),
                Password  = GetValue(bindingContext, "password"),
                Scope     = GetValue(bindingContext, "scope")
            };

            actionContext.ActionArguments[bindingContext.ModelName] = value;
            return(true);
        }