Example #1
0
 internal virtual void Run(Action pre, Action post)
 {
     pre.Call();
     if (Kean.Error.Log.CatchErrors)
         try
         {
             this.Method.Call();
         }
         catch (Exception)
         {
             Console.Write("F");
         }
     else
         this.Method.Call();
     post.Call();
 }
Example #2
0
 public static RepeatThread Start(string name, Action task, Action<RepeatThread, Action> run)
 {
     RepeatThread result = new RepeatThread();
     Action wrappedTask = Error.Log.Wrap(string.Format("Thread \"{0}\" Failed.", name), () =>
         {
             try
             {
                 task.Call();
             }
             catch (System.Threading.ThreadInterruptedException) { result.End = true; }
             catch (System.Threading.ThreadAbortException) { result.End = true; }
         });
     run(result, () =>
         {
             result.Running = true;
             while (!result.End)
                 wrappedTask();
             result.Running = false;
         });
     return result;
 }
Example #3
0
		public void Add(char shortIdentifier, string longIdentifier, Action<string, string, string, string> handler)
		{
			this.Add(shortIdentifier, longIdentifier, 4, s => handler.Call(s[0], s[1], s[2], s[3]));
		}
Example #4
0
 public bool Resolve(Uri.Locator locator, Action<object> set)
 {
     bool result;
     object target = this.targets[locator];
     if (result = target.NotNull())
         set.Call(target);
     else
     {
         Action<object> looseEnd = this.looseEnds[locator];
         if (looseEnd.NotNull())
             looseEnd += set;
         else
             this.looseEnds[locator] = set;
     }
     return result;
 }
Example #5
0
		/// <summary>
		/// Adds a new argument handler to the parser.
		/// Used for arguments with 0 parameters.
		/// </summary>
		/// <param name="shortIdentifier">Argument short form character (for example v for -v).</param>
		/// <param name="longIdentifier">Argument long form string (for example version for --version).</param>
		/// <param name="handler">Function to call when argument is found during parsing.</param>
		public void Add(char shortIdentifier, string longIdentifier, Action handler)
		{
			this.Add(shortIdentifier, longIdentifier, 0, s => handler.Call());
		}