예제 #1
0
 public static OicResponse CreateMessage(OicResponseCode code, string message)
 {
     return(new OicResponse
     {
         ResposeCode = code,
         ContentType = OicMessageContentType.ApplicationJson,
         Content = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { message = message }))
     });
 }
예제 #2
0
 public OicException(string message, Exception innerException, OicResponseCode code)
     : base(message, innerException)
 {
     ResponseCode = code;
 }
예제 #3
0
 public OicException(string message, Exception innerException)
     : base(message, innerException)
 {
     ResponseCode = OicResponseCode.InternalServerError;
 }
예제 #4
0
 public OicException(string message, OicResponseCode code)
     : base(message)
 {
     ResponseCode = code;
 }
예제 #5
0
        public static CoapMessageCode ToCoapMessageCode(this OicResponseCode code)
        {
            switch (code)
            {
            case OicResponseCode.Created:
                return(CoapMessageCode.Created);

            case OicResponseCode.Deleted:
                return(CoapMessageCode.Deleted);

            case OicResponseCode.Valid:
                return(CoapMessageCode.Valid);

            case OicResponseCode.Changed:
                return(CoapMessageCode.Changed);

            case OicResponseCode.Content:
                return(CoapMessageCode.Content);

            case OicResponseCode.BadRequest:
                return(CoapMessageCode.BadRequest);

            case OicResponseCode.Unauthorized:
                return(CoapMessageCode.Unauthorized);

            case OicResponseCode.BadOption:
                return(CoapMessageCode.BadOption);

            case OicResponseCode.Forbidden:
                return(CoapMessageCode.Forbidden);

            case OicResponseCode.NotFound:
                return(CoapMessageCode.NotFound);

            case OicResponseCode.OperationNotAllowed:
                return(CoapMessageCode.MethodNotAllowed);

            case OicResponseCode.NotAcceptable:
                return(CoapMessageCode.NotAcceptable);

            case OicResponseCode.PreconditionFailed:
                return(CoapMessageCode.PreconditionFailed);

            case OicResponseCode.RequestEntityTooLarge:
                return(CoapMessageCode.RequestEntityTooLarge);

            case OicResponseCode.UnsupportedContentType:
                return(CoapMessageCode.UnsupportedContentFormat);

            case OicResponseCode.InternalServerError:
                return(CoapMessageCode.InternalServerError);

            case OicResponseCode.NotImplemented:
                return(CoapMessageCode.NotImplemented);

            case OicResponseCode.BadGateway:
                return(CoapMessageCode.BadGateway);

            case OicResponseCode.ServiceUnavailable:
                return(CoapMessageCode.ServiceUnavailable);

            case OicResponseCode.GatewayTimeout:
                return(CoapMessageCode.GatewayTimeout);

            case OicResponseCode.ProxyingNotSupported:
                return(CoapMessageCode.ProxyingNotSupported);

            default:
                throw new OicException("Unsupported response code", new ArgumentOutOfRangeException(nameof(code), code, null));
            }
        }