/// <summary>
 /// Creates Success result.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="messages">Message list.</param>
 internal Result(A value, IMessageList <Message> messages)
 {
     State      = ResultState.Success;
     Value      = value;
     ErrorValue = default;
     Messages   = messages;
 }
 /// <summary>
 /// Creates failed result.
 /// </summary>
 /// <param name="error">Error value.</param>
 /// <param name="messages">Message list.</param>
 internal Result(Error error, IMessageList <Message> messages)
 {
     State      = ResultState.Error;
     Value      = default;
     ErrorValue = error;
     Messages   = messages;
 }
예제 #3
0
 static void UseInterface(IMessageList list)
 {
     Log("UseInterface() being called in AppDomain #{0}",
         AppDomain.CurrentDomain.Id);
     if (null == list)
     {
         throw new ArgumentNullException("list");
     }
     list.Add("Mike");
 }
        public Result <ParsedObject, Exception, string> Parse(string source)
        {
            ParsedObject parsedObject = new ParsedObject();

            IMessageList <string> errors      = MessageList <string> .Empty;
            IMessageList <string> messageList = MessageList <string> .Empty;

            ParseA(source)
            .MatchSuccess((a, list) => parsedObject.A = a)
            .MatchError((e, list) => errors           = errors.AddRange(list))
            .MatchMessages(list => messageList        = messageList.AddRange(list));

            ParseB(source)
            .MatchSuccess((b, list) => parsedObject.B = b)
            .MatchError((e, list) => errors           = errors.AddRange(list))
            .MatchMessages(list => messageList        = messageList.AddRange(list));

            return(errors.Count == 0
                ? parsedObject.ToSuccess(messageList)
                : messageList.ToFail <ParsedObject, Exception, string>());
        }
 public EventService(IMessageList messageList, IUnitOfWork unitOfWork) : base(messageList, unitOfWork)
 {
 }
예제 #6
0
 public CountryService(IMessageList messageList, IUnitOfWork unitOfWork) : base(messageList, unitOfWork)
 {
 }
 public ServiceBase(IMessageList messageList, IUnitOfWork unitOfWork)
 {
     _messageList = messageList;
     _unitOfWork  = unitOfWork;
 }
예제 #8
0
 /// <summary>
 /// Deconstructs values.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="messages">Message list.</param>
 public void Deconstruct(out A value, out IMessageList <Message> messages)
 {
     value    = Value;
     messages = Messages;
 }
예제 #9
0
 /// <summary>
 /// Creates value with messages.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="message">Single Message.</param>
 public ValueWithMessages(A value, Message message)
 {
     Value    = value.AssertArgumentNotNull(nameof(value));
     Messages = message.AssertArgumentNotNull(nameof(message)).ToMessageList();
 }
예제 #10
0
 /// <summary>
 /// Creates value with messages.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="messages">Message list.</param>
 public ValueWithMessages(A value, IEnumerable <Message> messages)
 {
     Value    = value.AssertArgumentNotNull(nameof(value));
     Messages = messages.AssertArgumentNotNull(nameof(messages)).ToMessageList();
 }
 public ProjectBL(IUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
     _messages   = UnityConfig.Container.Resolve <IMessageList>();
 }
 public ProjectBL(IUnitOfWork unitOfWork, IMessageList message)
 {
     _unitOfWork = unitOfWork;
     _messages   = message;
 }