コード例 #1
0
        public ICommandStrategy <TResource> GetOrThrow(UnsafeMethod method)
        {
            if (!ContainsKey(method))
            {
                throw new MethodNotAllowedException(method, typeof(TResource));
            }

            return(this[method]);
        }
コード例 #2
0
        private async Task <IHttpActionResult> GetResultFromMethodFeedbackAsync(UnsafeMethod method, ResourceBody body)
        {
            IRestEndpoint endpoint = GetEndpoint();

            if (!endpoint.EvaluatePreconditions(GetPreconditions()))
            {
                return(StatusCode(HttpStatusCode.PreconditionFailed));
            }

            Feedback feedback = await endpoint.CommandAsync(method, body);

            return(GetResultFromFeedback(feedback));
        }
コード例 #3
0
        public Task <Feedback> CommandAsync(UnsafeMethod method, ResourceBody body)
        {
            ICommandStrategy <IRestCollection> strategy = Context.Services.Strategies.ForCollections.GetOrThrow(method);

            return(strategy.ExecuteAsync(Collection, Context, body));
        }
コード例 #4
0
 internal MethodNotAllowedException(UnsafeMethod method, Type resourceType)
     : base(ErrorStatus.MethodNotAllowed, GetMessage(method, resourceType))
 {
 }
コード例 #5
0
        private static string GetMessage(UnsafeMethod method, Type resourceType)
        {
            string resourceTypeName = resourceType.Name.Replace("IRest", string.Empty).ToLower();

            return("The " + method.ToString().ToUpper() + " method is not allowed on a " + resourceTypeName);
        }
コード例 #6
0
 public Task <Feedback> CommandAsync(UnsafeMethod method, ResourceBody body)
 {
     throw new NotImplementedException("Not implemented unsafe strategies on dictionaries yet.");
     // TODO could implement PUTs with multi updates ?
 }
コード例 #7
0
 public Task <Feedback> CommandAsync(UnsafeMethod method, ResourceBody body)
 {
     throw new MethodNotAllowedException("Only safe methods are allowed on the directory.");
 }