/// <summary>
        /// Converts to.
        /// </summary>
        /// <param name="sqlException">The SQL exception.</param>
        /// <returns>Beyova.ExceptionSystem.BaseException.</returns>
        public static BaseException ConvertTo(SqlStoredProcedureException sqlException)
        {
            BaseException result = null;

            if (sqlException != null)
            {
                switch (sqlException.Code.Major)
                {
                    case ExceptionCode.MajorCode.NullOrInvalidValue:
                        result = new InvalidObjectException(sqlException, reason: sqlException.Code.Minor);
                        break;
                    case ExceptionCode.MajorCode.UnauthorizedOperation:
                        result = new UnauthorizedOperationException(sqlException, reason: sqlException.Code.Minor);
                        break;
                    case ExceptionCode.MajorCode.OperationForbidden:
                        result = new OperationForbiddenException(sqlException.Code.Minor, sqlException);
                        break;
                    case ExceptionCode.MajorCode.DataConflict:
                        result = new DataConflictException(sqlException.Code.Minor, innerException: sqlException);
                        break;
                    default:
                        result = sqlException;
                        break;
                }
            }

            return result;
        }
        /// <summary>
        /// To the exception.
        /// </summary>
        /// <param name="exceptionInfo">The exception information.</param>
        /// <returns>System.Exception.</returns>
        public static Exception ToException(this ExceptionInfo exceptionInfo)
        {
            Exception result = null;

            if (exceptionInfo != null)
            {
                var innerException = exceptionInfo.InnerException;

                switch (exceptionInfo.ExceptionType)
                {
                    case "Beyova.ExceptionSystem.HttpOperationException":
                        return new HttpOperationException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                    case "Beyova.ExceptionSystem.SqlStoredProcedureException":
                        return new SqlStoredProcedureException(exceptionInfo.Message, exceptionInfo.Code);
                    default:
                        break;
                }

                switch (exceptionInfo.Code.Major)
                {
                    case ExceptionCode.MajorCode.CreditNotAfford:
                        result = new CreditNotAffordException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.DataConflict:
                        result = new DataConflictException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.NotImplemented:
                        result = new UnimplementedException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.NullOrInvalidValue:
                        result = new InvalidObjectException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.OperationFailure:
                        result = new OperationFailureException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.OperationForbidden:
                        result = new OperationForbiddenException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.ResourceNotFound:
                        result = new ResourceNotFoundException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.ServiceUnavailable:
                        result = new InitializationFailureException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.UnauthorizedOperation:
                        result = new UnauthorizedOperationException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.HttpBlockError:
                        result = new HttpOperationException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    case ExceptionCode.MajorCode.Unsupported:
                        result = new UnsupportedException(exceptionInfo.Key ?? Guid.NewGuid(), exceptionInfo.CreatedStamp ?? DateTime.UtcNow, exceptionInfo.Message, exceptionInfo.Scene, exceptionInfo.Code, ToException(innerException), exceptionInfo.OperatorCredential, exceptionInfo.Data, exceptionInfo.Hint);
                        break;
                    default:
                        result = new Exception(exceptionInfo.Message);
                        break;
                }
            }

            return result;
        }