Пример #1
0
        internal HttpResult(HttpResultStatus status, Maybe <T> value, IHttpState httpState)
        {
            if (status == HttpResultStatus.Ok && value.HasNoValue)
            {
                throw new ArgumentNullException(nameof(value), HttpResultMessages.SuccessResultMustHaveValue);
            }

            _httpResultStatus = status;
            _httpState        = httpState ?? throw new ArgumentNullException(nameof(httpState));
            _value            = status == HttpResultStatus.Ok ? value : Maybe <T> .Nothing;
        }
        public bool Equals(IHttpState other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            var otherHttpStateTest = other as HttpStateTest;

            return(Equals(otherHttpStateTest));
        }
        internal HttpResult(
            HttpResultStatus status,
            Maybe <TValue> value,
            Maybe <TError> error,
            IHttpState httpState)
        {
            if (status == HttpResultStatus.Fail && error.HasNoValue)
            {
                throw new ArgumentNullException(nameof(error), HttpResultMessages.FailureResultMustHaveError);
            }

            if (status == HttpResultStatus.Ok && value.HasNoValue)
            {
                throw new ArgumentNullException(nameof(value), HttpResultMessages.SuccessResultMustHaveValue);
            }

            _value            = value;
            _error            = error;
            _httpState        = httpState ?? throw new ArgumentNullException(nameof(httpState));
            _httpResultStatus = status;
        }
Пример #4
0
 public static HttpResultWithError <T> Fail <T>(T error, IHttpState httpState)
 {
     return(new HttpResultWithError <T>(HttpResultStatus.Fail, error, httpState));
 }
Пример #5
0
 public static HttpResultWithError <T> Ok <T>(IHttpState httpState)
 {
     return(new HttpResultWithError <T>(HttpResultStatus.Ok, Maybe <T> .Nothing, httpState));
 }
 private HttpResult(HttpResultStatus httpResultStatus, IHttpState httpState)
 {
     _httpResultStatus = httpResultStatus;
     _httpState        = httpState ?? throw new ArgumentNullException(nameof(httpState));
 }
 public static HttpResult <TValue, TError> Fail <TValue, TError>(TError error, IHttpState httpState)
 {
     return(new HttpResult <TValue, TError>(HttpResultStatus.Fail, Maybe <TValue> .Nothing, error, httpState));
 }
 public static HttpResult <TValue, TError> Ok <TValue, TError>(TValue value, IHttpState httpState)
 {
     return(new HttpResult <TValue, TError>(HttpResultStatus.Ok, value, Maybe <TError> .Nothing, httpState));
 }
 public static HttpResult <TValue> Fail <TValue>(IHttpState httpState)
 {
     return(new HttpResult <TValue>(HttpResultStatus.Fail, Maybe <TValue> .Nothing, httpState));
 }
 public static HttpResult <TValue> Ok <TValue>(TValue value, IHttpState httpState)
 {
     return(new HttpResult <TValue>(HttpResultStatus.Ok, value, httpState));
 }
 public static HttpResult Fail(IHttpState httpState)
 {
     return(new HttpResult(HttpResultStatus.Fail, httpState));
 }
 public static HttpResult Ok(IHttpState httpState)
 {
     return(new HttpResult(HttpResultStatus.Ok, httpState));
 }
Пример #13
0
 public static object GetStateValue(IHttpState state, string key)
 {
     return(state.GetValue(key));
 }