Exemple #1
0
 public static OicRequest Create(string path, OicRequestOperation operation = OicRequestOperation.Get)
 {
     return(new OicRequest
     {
         Accepts =
         {
             OicMessageContentType.ApplicationCbor,
             OicMessageContentType.ApplicationJson
         },
         Operation = operation,
         ToUri = new Uri(path, UriKind.RelativeOrAbsolute)
     });
 }
        public static CoapMessageCode ToCoapMessageCode(this OicRequestOperation code)
        {
            switch (code)
            {
            case OicRequestOperation.Get:
                return(CoapMessageCode.Get);

            case OicRequestOperation.Post:
                return(CoapMessageCode.Post);

            case OicRequestOperation.Put:
                return(CoapMessageCode.Put);

            case OicRequestOperation.Delete:
                return(CoapMessageCode.Delete);

            default:
                throw new OicException("Unsupported operation", new ArgumentOutOfRangeException(nameof(code), code, null), OicResponseCode.BadRequest);
            }
        }