Exemplo n.º 1
0
 /// <summary>
 /// Returns the value in case it is initialized.
 /// Otherwise throws an <see cref="InvalidOperationException"/>.
 /// </summary>
 /// <param name="maybeParameterName">The maybe reference used in error message.</param>
 /// <param name="additionalMessage">Additional error message.</param>
 /// <returns>The value.</returns>
 public T ValueOrException(
     string maybeParameterName,
     string additionalMessage = "")
 {
     return(MaybeUtils.CheckParameterNotNull(this.value, maybeParameterName, additionalMessage)
            .Value);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the value in case it is initialized.
        /// Otherwise throws an <see cref="InvalidOperationException"/>.
        /// </summary>
        /// <param name="maybeParameterName">The maybe reference used in error message.</param>
        /// <param name="additionalMessage">Additional error message.</param>
        /// <returns>The value.</returns>
        public T ValueOrException(
            string maybeParameterName = "",
            string additionalMessage  = "")
        {
            var parameterName = maybeParameterName;

            if (string.IsNullOrEmpty(maybeParameterName))
            {
                parameterName = typeof(T).Name;
            }

            return(MaybeUtils.CheckParameterNotNull(this.value, parameterName, additionalMessage));
        }