示例#1
0
        internal Order(NonEmptyString propertyName, bool isAscending)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException("propertyName");
            }

            this.PropertyName = propertyName;
            this.IsAscending  = isAscending;
        }
        private void LogLinqModifierName(NonEmptyString linqModifier, QueryModifiers queryModifiers)
        {
            Debug.Assert(!linqModifier.ToString().IsBlank());
            this.LogInformationData("LINQ Modifier", linqModifier);

            if (queryModifiers != null)
            {
                this.LogInformationData("Query Modifiers", queryModifiers);
            }
        }
示例#3
0
        /// <summary>
        ///     Joins text information from the chain of exceptions including inner ones.
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="separator"></param>
        /// <param name="innerFirst">True to put innermost exception on top, false for outermost.</param>
        /// <param name="converter"></param>
        /// <returns></returns>
        public static string Consolidate(this Exception ex, string separator, bool innerFirst, Func <Exception, string> converter)
        {
            if (separator == null)
            {
                separator = defaultItemSeparator;
            }

            separator = "\r\n{0}\r\n".SmartFormat(separator);

            Func <Exception, IEnumerable <Exception> > iterator = innerFirst ? AllExceptions : new Func <Exception, IEnumerable <Exception> >(AllExceptionsBack);

            NonEmptyString retVal = string.Join(separator, iterator(ex).Select(converter));

            return(retVal);
        }
示例#4
0
        /// <summary>
        ///     Sends SMTP email using .config file settings.
        /// </summary>
        /// <param name="isBodyHtml"></param>
        /// <param name="optioanlFromAddress">If null, .config from address value is used.</param>
        /// <param name="optionalReplyToAddress">If null, reply-to address is the same as from address.</param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="toAddresses"></param>
        public static void SendSmtpEmail(bool isBodyHtml, NonEmptyString optioanlFromAddress, NonEmptyString optionalReplyToAddress, string subject, string body, params string[] toAddresses)
        {
            if (toAddresses != null)
            {
                toAddresses = toAddresses.Where(addr => !addr.IsBlank()).ToArray();
            }

            if (toAddresses.IsNullOrEmpty())
            {
                throw new Exception("\"To\" address must be specified");
            }

            if (subject.IsBlank() && body.IsBlank())
            {
                throw new Exception("Both subject and message body cannot be blank.");
            }

            MailMessage message = new MailMessage();

            if (optioanlFromAddress != null)
            {
                message.From = new MailAddress(optioanlFromAddress);
            }

            if (optionalReplyToAddress != null)
            {
                message.ReplyToList.Add(new MailAddress(optionalReplyToAddress));
            }

            toAddresses.ForEach(toAddr => message.To.Add(new MailAddress(toAddr)));

            message.Subject    = subject;
            message.Body       = body;
            message.IsBodyHtml = isBodyHtml;

            SmtpClient smtpClient = SmtpClientFactory == null ? null : SmtpClientFactory();

            if (smtpClient == null)
            {
                smtpClient = new SmtpClient();
            }

            using (smtpClient)
            {
                smtpClient.Send(message);
            }
        }
示例#5
0
 internal ThenOrder(NonEmptyString propertyName, bool isAscending) : base(propertyName, isAscending)
 {
 }