public bool TryEvaluate(object sender, VariableEvaluationEventArg e) { Match loremIspumVariableEvalMatch = loremIspumVariableEvalRegex.Match(e.Name); if (loremIspumVariableEvalMatch.Success) { LoremIpsum li = new LoremIpsum(); if (loremIspumVariableEvalMatch.Groups["language"].Success) { li.CurrentLanguage = loremIspumVariableEvalMatch.Groups["language"].Value.ToLower(); } int wordPerLine = loremIspumVariableEvalMatch.Groups["wordsPerLine"].Success ? int.Parse(loremIspumVariableEvalMatch.Groups["wordsPerLine"].Value, CultureInfo.InvariantCulture) : 10; if (loremIspumVariableEvalMatch.Groups["words"].Success) { e.Value = li.GetWords(int.Parse(loremIspumVariableEvalMatch.Groups["words"].Value, CultureInfo.InvariantCulture), wordPerLine); } else { e.Value = loremIspumVariableEvalMatch.Groups["lines"].Success ? li.GetLines(int.Parse(loremIspumVariableEvalMatch.Groups["lines"].Value, CultureInfo.InvariantCulture), wordPerLine) : li.GetWords(100, wordPerLine); } return(true); } else { return(false); } }
protected string GetRandomString(int wordCount) { LoremIpsum lipsum = new LoremIpsum(); return(lipsum.GetWords(wordCount, true)); }