/// <summary> /// Determine the points for the given Receiving PMode and UserMessage /// </summary> /// <param name="pmode"></param> /// <param name="userMessage"></param> /// <returns></returns> public int DeterminePoints(ReceivingProcessingMode pmode, UserMessage userMessage) { if (pmode == null) { throw new ArgumentNullException(nameof(pmode)); } if (userMessage == null) { throw new ArgumentNullException(nameof(userMessage)); } Model.PMode.CollaborationInfo pmodeCollaboration = pmode.MessagePackaging?.CollaborationInfo; Model.Core.CollaborationInfo messageCollaboration = userMessage.CollaborationInfo; if (pmodeCollaboration == null) { return(NotEqual); } bool equalAction = StringComparer .OrdinalIgnoreCase .Equals(pmodeCollaboration.Action, messageCollaboration.Action); bool noServiceType = pmodeCollaboration.Service?.Type == null && messageCollaboration.Service.Type == Maybe <string> .Nothing; bool equalServiceType = messageCollaboration.Service.Type .Select(t => StringComparer.OrdinalIgnoreCase.Equals(pmodeCollaboration.Service?.Type, t)) .GetOrElse(false); bool equalServiceValue = StringComparer .OrdinalIgnoreCase .Equals(pmodeCollaboration?.Service?.Value, messageCollaboration.Service.Value); bool equalService = equalServiceValue && (noServiceType || equalServiceType); return(equalAction && equalService ? Points : NotEqual); }
private static Xml.CollaborationInfo MapCollaborationInfo(Model.Core.CollaborationInfo model) { Xml.AgreementRef agreementRef = model.AgreementReference .Select(a => new Xml.AgreementRef { Value = a.Value, type = a.Type.GetOrElse(() => null), pmode = a.PModeId.GetOrElse(() => null) }) .GetOrElse(() => null); return(new Xml.CollaborationInfo { Action = model.Action, ConversationId = model.ConversationId, Service = new Xml.Service { Value = model.Service.Value, type = model.Service.Type.GetOrElse(() => null) }, AgreementRef = agreementRef }); }
private static Model.Core.CollaborationInfo RemoveResponsePostfixToActionWhenEmpty(Model.Core.CollaborationInfo mapped) { if (mapped == null) { return(new Model.Core.CollaborationInfo( Maybe <Model.Core.AgreementReference> .Nothing, Model.Core.Service.TestService, Constants.Namespaces.TestAction, Model.Core.CollaborationInfo.DefaultConversationId)); } string action = mapped.Action; if (!String.IsNullOrWhiteSpace(action) && action.EndsWith(".response", StringComparison.OrdinalIgnoreCase)) { return(new Model.Core.CollaborationInfo( mapped.AgreementReference, mapped.Service, action.Substring(0, action.LastIndexOf(".response", StringComparison.OrdinalIgnoreCase)), mapped.ConversationId)); } return(mapped); }