/// <summary> /// Maps from a domain model representation of an AS4 usermessage to an XML representation of an AS4 routing usermessage. /// </summary> /// <param name="model">The domain model to convert.</param> internal static Xml.RoutingInputUserMessage ConvertToRouting(Model.Core.UserMessage model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var r = new Xml.RoutingInputUserMessage { MessageInfo = new Xml.MessageInfo { MessageId = model.MessageId, RefToMessageId = model.RefToMessageId, Timestamp = model.Timestamp.LocalDateTime }, mpc = model.Mpc, CollaborationInfo = MapCollaborationInfo(model.CollaborationInfo), PartyInfo = MapPartyInfo(model.Receiver, model.Sender), MessageProperties = MapMessageProperties(model.MessageProperties), PayloadInfo = MapPartInfos(model.PayloadInfo) }; r.mpc = r.mpc ?? Constants.Namespaces.EbmsDefaultMpc; r.CollaborationInfo.Action = r.CollaborationInfo.Action + ".response"; return(r); }
/// <summary> /// Maps from an XML representation of an AS4 routing usermessage to a domain model representation of an AS4 usermessage. /// </summary> /// <param name="xml">The XML representation to convert.</param> internal static Model.Core.UserMessage ConvertFromRouting(Xml.RoutingInputUserMessage xml) { if (xml == null) { throw new ArgumentNullException(nameof(xml)); } return(new Model.Core.UserMessage( messageId: xml.MessageInfo?.MessageId, refToMessageId: xml.MessageInfo?.RefToMessageId, timestamp: xml.MessageInfo?.Timestamp.ToDateTimeOffset() ?? DateTimeOffset.Now, mpc: String.IsNullOrEmpty(xml.mpc) ? Constants.Namespaces.EbmsDefaultMpc : xml.mpc, collaboration: RemoveResponsePostfixToActionWhenEmpty(MapCollaborationInfo(xml.CollaborationInfo)), sender: MapParty(xml.PartyInfo?.From), receiver: MapParty(xml.PartyInfo?.To), partInfos: MapPartInfos(xml.PayloadInfo).ToArray(), messageProperties: MapMessageProperties(xml.MessageProperties).ToArray())); }