Ejemplo n.º 1
0
        private string CreateBody(PropertyMessageTypeEnum messageType)
        {
            string bodyTemplate = _templateDataService.GetString(GetBodyTemplateName(messageType));

            if (bodyTemplate == null)
            {
                throw new NullReferenceException(nameof(bodyTemplate));
            }

            foreach (Match m in  Regex.Matches(bodyTemplate, @"\[.*?\]"))
            {
                var placeholder  = m.Value;
                var parameterStr = placeholder.Trim('[', ']');
                if (!Enum.TryParse(parameterStr, true, out PropertyMessageParamsEnum parameter))
                {
                    throw new InvalidEnumArgumentException(nameof(parameterStr));
                }
                string value = GetParameterValue(parameter);
                if (string.IsNullOrEmpty(value))
                {
                    throw new NoNullAllowedException($"Empty value for placeholder {placeholder}");
                }

                bodyTemplate = bodyTemplate.Replace(placeholder, value);
            }

            return(bodyTemplate);
        }
Ejemplo n.º 2
0
        private string CreateSubject(PropertyMessageTypeEnum messageType)
        {
            var template = _templateDataService.GetString(GetSubjectTemplateName(messageType));

            if (template == null)
            {
                throw new NullReferenceException(nameof(template));
            }
            return(template);
        }
 public PropertyMessage(PropertyMessageTypeEnum messageType, PartyInfo sender, PartyInfo recipient)
 {
     MessageType = messageType;
     Sender      = sender;
     Recipient   = recipient;
 }
Ejemplo n.º 4
0
 private string GetBodyTemplateName(PropertyMessageTypeEnum messageType)
 {
     return(messageType + "Template");
 }
Ejemplo n.º 5
0
 private string GetSubjectTemplateName(PropertyMessageTypeEnum messageType)
 {
     return(messageType.ToString() + "SubjectTemplate");
 }