﻿namespace DatabaseDoc
{
    using System;

    internal static class StringExtensions
    {
        public static bool? ToBoolean(this string value, bool? defaultValue = null)
        {            
            if (string.IsNullOrWhiteSpace(value))
            {
                return defaultValue;
            }

            if (string.Compare(value, "Y", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return true;
            }

            if (string.Compare(value, "N", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return false;
            }

            return defaultValue;
        }
    }
}