Beispiel #1
0
        /// <summary>
        /// The MethodInfo associated with the given HTTP method and resource URI,
        /// as annotated by a ResourceActionAttribute, or null if no match is found.
        /// </summary>
        public static MethodInfo GetAction(this Type type, string httpMethod, string resourceUri)
        {
            var attribute = ResourceActionAttribute.Create(httpMethod, resourceUri);

            return(type.GetResourceActions()
                   .FirstOrDefault(action => action.GetResourceActionAttribute().Contains(attribute)));
        }
 public void CreateIsCaseInsensitive()
 {
     Assert.That(ResourceActionAttribute.Create("get", "test"), Is.EqualTo(new GetAttribute("test")));
 }
 public void CreateShouldReturnNullIfInvalidMethodGiven()
 {
     Assert.That(ResourceActionAttribute.Create("TRACE", "test"), Is.Null);
 }
 public void DeleteCreateShouldReturnDeleteAttribute()
 {
     Assert.That(ResourceActionAttribute.Create("DELETE", "test"), Is.EqualTo(new DeleteAttribute("test")));
 }
 public void PutCreateShouldReturnPutAttribute()
 {
     Assert.That(ResourceActionAttribute.Create("PUT", "test"), Is.EqualTo(new PutAttribute("test")));
 }
 public void GetCreateShouldReturnGetAttribute()
 {
     Assert.That(ResourceActionAttribute.Create("GET", "test"), Is.EqualTo(new GetAttribute("test")));
 }