Exemple #1
0
        /// <summary>
        /// Gets the trial string.
        /// </summary>
        /// <param name="stringToModify">The string to modify.</param>
        /// <param name="trialStringType">Type of the trial string.</param>
        /// <returns></returns>
        public static string GetTrialString(string stringToModify, TrialStringType trialStringType)
        {
            // Ensure that we have something to work with
            if (stringToModify == null)
            {
                stringToModify = string.Empty;
            }

            // Create the random texts
            Random random = new Random();

            string shortText = GetRandomString(9 + random.Next(5));
            string longText  = string.Format(" (This email has been created using the trial version of ActiveUp.MailSystem. When you register the product, this message and all trial texts disappear. In addition of this text, the subject, the attachment filenames and the recipient/sender names are modified with a random trial string (ex:{0}). http://www.activeup.com) ", shortText);

            int randomPosition = random.Next(stringToModify.Length);

            // Apply the texts
            switch (trialStringType)
            {
            case TrialStringType.ShortText:
            default:
                return(stringToModify.Insert(randomPosition, shortText));

            case TrialStringType.LongHtml:
                return(stringToModify.Insert(randomPosition, string.Format("<table bgcolor=\"#F00000\" border=\"1\"><tr><td>{0}</td></tr></table>", longText)));

            case TrialStringType.LongText:
                return(stringToModify.Insert(randomPosition, longText));
            }
        }
        /// <summary>
        /// Gets the trial string.
        /// </summary>
        /// <param name="stringToModify">The string to modify.</param>
        /// <param name="trialStringType">Type of the trial string.</param>
        /// <returns></returns>
        public static string GetTrialString(string stringToModify, TrialStringType trialStringType)
        {
            // Ensure that we have something to work with
            if (stringToModify == null) stringToModify = string.Empty;

            // Create the random texts
            Random random = new Random();

            string shortText = GetRandomString(9 + random.Next(5));
            string longText = string.Format(" (This email has been created using the trial version of ActiveUp.MailSystem. When you register the product, this message and all trial texts disappear. In addition of this text, the subject, the attachment filenames and the recipient/sender names are modified with a random trial string (ex:{0}). http://www.activeup.com) ", shortText);

            int randomPosition = random.Next(stringToModify.Length);

            // Apply the texts
            switch (trialStringType)
            {
                case TrialStringType.ShortText:
                default:
                    return stringToModify.Insert(randomPosition, shortText);
                    break;
                case TrialStringType.LongHtml:
                    return stringToModify.Insert(randomPosition, string.Format("<table bgcolor=\"#F00000\" border=\"1\"><tr><td>{0}</td></tr></table>", longText));
                    break;
                case TrialStringType.LongText:
                    return stringToModify.Insert(randomPosition, longText);
                    break;
            }
        }