/// <summary>
        /// Converts IDictionary to delimited string.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="delimiter">The delimiter.</param>
        /// <returns>System.String.</returns>
        internal static string ToDelimitedString([NotNull] this IDictionary list, char delimiter = ',')
        {
            if (string.IsNullOrEmpty(delimiter.ToString()))
            {
                ExceptionThrower.ThrowArgumentNullException(nameof(delimiter));
            }

            if (list.Count() == 0)
            {
                return(string.Empty);
            }

            var sb = new StringBuilder();

            foreach (DictionaryEntry item in list)
            {
                if (sb.Length > 0)
                {
                    _ = sb.Append(delimiter.ToString(CultureInfo.CurrentCulture));
                }

                _ = sb.Append($"{item.Key}: {item.Value}".ToString(CultureInfo.CurrentCulture));
            }

            return(sb.ToString());
        }
Beispiel #2
0
        public static DirectoryInfo ArgumentExists(this DirectoryInfo input, DirectoryInfo?defaultValue = null, string errorMessage = "", [CallerArgumentExpression("input")] string paramName = "")
        {
            if (input.CheckIsNotNull() is false)
            {
                ExceptionThrower.ThrowArgumentNullException(CreateParamExceptionMessage(errorMessage, paramName, Resources.ErrorArgumentNull));
            }

            var isValid = input !.Exists;

            if (isValid is false && defaultValue is not null)
            {
                input = defaultValue !;
            }