/// <summary> /// Sets a command in this context. If the command exists, it is set in /// the context in which it was declared. Otherwise, it is declared in this context. /// </summary> /// <param name="name">the command name</param> /// <param name="func">the delegate to the command</param> public void SetCommand(string name, TBasicFunction func) { ObjectContext c = FindCommandContext(name); if (c == null) { _commands.Add(name, func); #if SHOW_OBJECTS Console.WriteLine("{1} command declared in {1}", GetHashCode(), name); #endif } else { c._commands[name] = func; #if SHOW_OBJECTS Console.WriteLine("{0} command set in {1}", c.GetHashCode(), name); #endif } }
/// <summary> /// Sets a function in this context. If the function exists, it is set in /// the context in which it was declared. Otherwise, it is declared in this context. /// </summary> /// <param name="name">the function name</param> /// <param name="func">the delegate to the function</param> public void SetFunction(string name, TBasicFunction func) { ObjectContext c = FindFunctionContext(name); if (c == null) { _functions.Add(name, func); #if SHOW_OBJECTS Console.WriteLine("{1} function declared in {0}", GetHashCode(), name); #endif } else { c._functions[name] = func; #if SHOW_OBJECTS Console.WriteLine("{1} function declared in {0}", c.GetHashCode(), name); #endif } }