コード例 #1
0
        internal ITransaction Map()
        {
            IOperationList operations = new OperationList();

            foreach (var item in Operations)
            {
                var rel = new LinkRelation(item.Rel);
                operations.Add(new HttpOperation(item.Href, rel, item.Method, item.ContentType));
            }

            var type  = string.IsNullOrEmpty(Type)? TransactionType.Unknown : Type.ParseTo <TransactionType>();
            var state = string.IsNullOrEmpty(State) ? "Unknown" : State;
            var id    = new Uri(Id, UriKind.RelativeOrAbsolute);

            var problem = Problem?.Map();

            var transaction = new Transaction(id,
                                              Created,
                                              Updated,
                                              type,
                                              state,
                                              Number,
                                              Amount,
                                              VatAmount,
                                              Description,
                                              PayeeReference,
                                              IsOperational,
                                              operations,
                                              Activity)
            {
                Problem = problem
            };

            return(transaction);
        }
コード例 #2
0
        public IOperationList Map()
        {
            var list = new OperationList();

            foreach (var item in this)
            {
                var rel = new LinkRelation(item.Rel);
                list.Add(new HttpOperation(item.Href, rel, item.Method, item.ContentType));
            }
            return(list);
        }
コード例 #3
0
 /// <summary>
 /// Instansiates a new <seealso cref="HttpOperation"/> with the provided parameters.
 /// </summary>
 /// <param name="href">The <seealso cref="Uri"/> for the operation.</param>
 /// <param name="rel">The name of the operation.</param>
 /// <param name="method">The <seealso cref="HttpMethod"/> as a string for the operation.</param>
 /// <param name="contentType">The content type of the operation.</param>
 public HttpOperation(Uri href, LinkRelation rel, string method, string contentType)
 {
     Href        = href;
     Rel         = rel;
     Method      = new HttpMethod(method);
     ContentType = contentType;
     if (href.Scheme == Uri.UriSchemeHttp || href.Scheme == Uri.UriSchemeHttps)
     {
         var request = new HttpRequestMessage(new HttpMethod(method), href);
         request.Headers.Add("Accept", contentType);
         Request = request;
     }
 }