protected HandlerMethodInvoker(HandlerMethod method)
 {
     if (method == null)
     {
         throw new ArgumentNullException(nameof(method));
     }
     Method = method;
 }
Beispiel #2
0
 public void Match_ChildResource_Takes_ParentResource()
 {
     var methodObject = new HandlerMethod(typeof(HandlerMethodTests).GetMethod("GetPlanetarySystems"),
                                          TypeMapper);
     Assert.That(
         methodObject.Match(HttpMethod.Get,
                            PathNodeType.Collection,
                            TypeMapper.FromType(typeof(PlanetarySystem))),
         Is.Not.Null);
 }
        public HandlerMethodTakingExistingResource(HandlerMethod method, ResourceType resourceType)
            : base(method)
        {
            if (resourceType == null)
            {
                throw new ArgumentNullException(nameof(resourceType));
            }
            this.resourceParameter =
                method.Parameters.LastOrDefault(x => x.Type == resourceType) ??
                method.Parameters.LastOrDefault(x => x.IsResource && x.Type.IsAssignableFrom(resourceType));

            if (this.resourceParameter == null)
            {
                throw new ArgumentException("Method has no argument accepting resource type.", nameof(method));
            }
        }
 public HandlerMethodTakingFormInvoker(HandlerMethod method,
                                       HandlerParameter formParameter,
                                       HandlerParameter targetResourceParameter = null)
     : base(method)
 {
     if (formParameter == null)
     {
         throw new ArgumentNullException(nameof(formParameter));
     }
     if (formParameter.Method != method)
     {
         throw new ArgumentException("Parameter provided does not belong to method.", nameof(formParameter));
     }
     if (targetResourceParameter != null && targetResourceParameter.Method != method)
     {
         throw new ArgumentException("Parameter provided does not belong to method.", nameof(targetResourceParameter));
     }
     this.formParameter           = formParameter;
     this.targetResourceParameter = targetResourceParameter;
 }
Beispiel #5
0
 public void Match_QueryMethod_Does_Not_Match_IncorrectMethodName()
 {
     var methodObject = new HandlerMethod(typeof(HandlerMethodTests).GetMethod("GetCrayons"), TypeMapper);
     Assert.That(
         methodObject.Match(HttpMethod.Get,
                            PathNodeType.Collection,
                            TypeMapper.FromType(typeof(Critter))),
         Is.Null);
 }
Beispiel #6
0
 public void Match_QueryMethod_PrefixedWithQuery_Matches_CorrectSignature()
 {
     var methodObject = new HandlerMethod(typeof(HandlerMethodTests).GetMethod("QueryCritters"), TypeMapper);
     Assert.That(
         methodObject.Match(HttpMethod.Get,
                            PathNodeType.Collection,
                            TypeMapper.FromType(typeof(Critter))),
         Is.Not.Null);
 }
Beispiel #7
0
 public HandlerParameter(ParameterInfo parameterInfo, HandlerMethod method)
 {
     this.parameterInfo = parameterInfo;
     Method = method;
 }
Beispiel #8
0
 public HandlerParameter(ParameterInfo parameterInfo, HandlerMethod method)
 {
     this.parameterInfo = parameterInfo;
     Method             = method;
 }
 public HandlerMethodTakingResourceId(HandlerMethod method)
     : base(method)
 {
 }
Beispiel #10
0
 public HandlerMethodTakingPatchedResource(HandlerMethod method, ResourceType resourceType)
     : base(method, resourceType)
 {
 }
 public HandlerMethodTakingPatchedResource(HandlerMethod method, ResourceType resourceType)
     : base(method, resourceType)
 {
 }