コード例 #1
0
        public HttpResponseMessage Test([FromBody] TestRequest request)
        {
            switch (request.ReturnHttpStatusCode)
            {
            case (int)HttpStatusCode.OK:
                return(this.Request.CreateResponse(new OkResponseStatus <TestResponse>(new TestResponse())));

            case (int)HttpStatusCode.InternalServerError:
                return(this.Request.CreateResponse(new ErrorResponseStatus <TestResponse>(new InternalServerResponseError())));

            case (int)HttpStatusCode.BadRequest:

                var error = new InvalidArgumentsResponseError(new List <ResponseArgumentError>
                {
                    new ResponseArgumentError
                    (
                        ArgumentName <TestRequest> .For(r => r.Val1),
                        new ArgumentErrorStub()
                    ),
                    new ResponseArgumentError
                    (
                        ArgumentName <TestRequest> .For(r => r.Val2),
                        new ArgumentErrorStub()
                    )
                });

                return(this.Request.CreateResponse(new ErrorResponseStatus <TestResponse>(error)));
            }

            throw new ArgumentOutOfRangeException("Http Status Code:" + request.ReturnHttpStatusCode + ". Not supported.");
        }
コード例 #2
0
ファイル: AttributeArgument.cs プロジェクト: aws/codelyzer
 public bool Equals(AttributeArgument compareNode)
 {
     return
         (compareNode != null &&
          ArgumentName?.Equals(compareNode.ArgumentName) != false &&
          ArgumentExpression?.Equals(compareNode.ArgumentExpression) != false &&
          base.Equals(compareNode));
 }
コード例 #3
0
        protected override object DoVisit(ArgumentName argumentName)
        {
            if (!arguments.Contains(argumentName.Name))
            {
                errorLogger.LogError(
                    argumentName.Location, Utilities.InvariantFormat("Argument with name \"{0}\" doesn't exist.", argumentName.Name));

                return(Error);
            }

            return(arguments[argumentName.Name].Value);
        }
コード例 #4
0
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="T:System.Object"/>.
 /// </returns>
 /// <filterpriority>2</filterpriority>
 public override Int32 GetHashCode()
 {
     unchecked
     {
         var hashCode = IsOptional.GetHashCode();
         hashCode = (hashCode * 397) ^ (DefaultValue != null ? DefaultValue.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ArgumentType != null ? ArgumentType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ArgumentName != null ? ArgumentName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Position.GetHashCode();
         return(hashCode);
     }
 }
コード例 #5
0
    public override int GetHashCode()
    {
        unchecked
        {
            var hashCode = Name.GetHashCode();
            hashCode = (hashCode * 397) ^ ArgumentName.GetHashCode();
            hashCode = (hashCode * 397) ^ TypeFullyQualifiedWithNullability.GetHashCode();
            hashCode = (hashCode * 397) ^ IsStatic.GetHashCode();
            hashCode = (hashCode * 397) ^ SpecialType.GetHashCode();
            hashCode = (hashCode * 397) ^ IsReferenceType.GetHashCode();

            return(hashCode);
        }
    }
コード例 #6
0
        private FieldDefinitionNode RewriteArgument(
            NameString schemaName,
            FieldDefinitionNode field)
        {
            var renamedArguments = new List <InputValueDefinitionNode>();

            foreach (InputValueDefinitionNode argument in field.Arguments)
            {
                if (ArgumentName.Equals(argument.Name.Value))
                {
                    renamedArguments.Add(argument.Rename(
                                             NewArgumentName, schemaName));
                }
                else
                {
                    renamedArguments.Add(argument);
                }
            }

            return(field.WithArguments(renamedArguments));
        }
コード例 #7
0
 protected override bool CheckArgument()
 {
     return(CommandLineArgs.IsPresent(ArgumentName.ToLowerInvariant()));
 }
コード例 #8
0
 public object Visit(ArgumentName argumentName)
 {
     return(DoVisit(Utilities.ThrowIfNull(argumentName, "argumentName")));
 }
コード例 #9
0
 protected virtual object DoVisit(ArgumentName argumentName)
 {
     return(Default(argumentName));
 }