/// <summary> /// Initializes a new instance of the <see cref="DelegateCommand"/> class. /// </summary> /// <param name="execute">Delegate to execute when Execute is called on the command.</param> /// <param name="canExecute">Delegate to execute when CanExecute is called on the command.</param> /// <exception cref="ArgumentNullException">The execute argument must not be null.</exception> public DelegateCommand(Action<object> execute, Func<object, bool> canExecute) { if (execute == null) { throw new ArgumentNullException("execute"); } _execute = execute; _canExecute = canExecute; }
static double computeSum(Func<long,double> element, long count) { double sum = 0; long n = 1; while (n<count) { sum += element(n); n++; } return sum; }
public static Func FindFunc(int index, string text) { Regex regexToFindFuncHead = new Regex(@"static\s+void\s[a-z,A-Z]*\s?\(.*\)"); Match funcMatchHead = regexToFindFuncHead.Match(text, index); if (funcMatchHead.Success) { string funcHead = funcMatchHead.Value; int numberOpenBracket = 0; int numberCloseBracket = 0; int lastBracketIndex = funcMatchHead.Index;// не наоборот?? int firsBracketIndex = text.IndexOf('{', lastBracketIndex); while ((numberCloseBracket == 0 & numberOpenBracket == 0) || numberCloseBracket != numberOpenBracket) { if (text.IndexOf('{', lastBracketIndex) > lastBracketIndex) { lastBracketIndex = text.IndexOf('{', lastBracketIndex); numberOpenBracket += 1; } if (text.IndexOf('}', lastBracketIndex) > lastBracketIndex) { lastBracketIndex = text.IndexOf('}', lastBracketIndex); numberCloseBracket += 1; } } string funcText = text.Substring(funcMatchHead.Index, lastBracketIndex - funcMatchHead.Index + 1); Func func = new Func( funcText, funcMatchHead.Index); return func; } else { return null; } }
/// <summary> /// Initializes a new instance of the <see cref="DelegateCommand"/> class. /// </summary> /// <param name="execute">Delegate to execute when Execute is called on the command.</param> /// <param name="canExecute">Delegate to execute when CanExecute is called on the command.</param> /// <exception cref="ArgumentNullException">The execute argument must not be null.</exception> public DelegateCommand(Action execute, Func<bool> canExecute) : this(execute != null ? p => execute() : (Action<object>)null, canExecute != null ? p => canExecute() : (Func<object, bool>)null) { }
private static void GenerateFunctions() { _84AvasomeFunctions = new List<Func<string, uint>>(); var r = new Random(); for (int i = 0; i < 84; i++) { int b = r.Next(5, 20); int simple = r.Next(b+1, b*2); var function = new Func<string, uint>(s => (uint) s.Select((t, j) => { return (t*((uint) Math.Pow(b, j)%simple)%simple); }).Sum()); _84AvasomeFunctions.Add(function); } }