public virtual void InitCommandConfig(string fileName) { if (fileName == null) { return; } Command.ResetCache(); if (command == null) { command = new Command(fileName); } else { command.FormatCommand(fileName); } InitCommandConfig(command); if (initNextScript) { NextScript(); } }
public virtual void InitCommandConfig(Stream ins) { if (ins == null) { return; } Command.ResetCache(); if (command == null) { command = new Command(ins); } else { command.FormatCommand(ins); } InitCommandConfig(command); if (initNextScript) { NextScript(); } }
public override void Dispose() { running = false; try { if (avgThread != null) { avgThread.Interrupt(); avgThread = null; } } catch (Exception) { } if (desktop != null) { desktop.Dispose(); desktop = null; } if (sprites != null) { sprites.Dispose(); sprites = null; } if (command != null) { command = null; } if (scrCG != null) { scrCG.Dispose(); scrCG = null; } if (dialog != null) { if (dialog.GetFileName() != null) { dialog.Destroy(); dialog = null; } } base.Dispose(); }
public abstract void InitCommandConfig(Command command);
public void SetCommand(Command command) { this.command = command; }
public string DoExecute() { if (isClose) { return null; } this.executeCommand = null; this.addCommand = true; this.isInnerCommand = (innerCommand != null); this.if_bool = false; this.elseif_bool = false; try { if (isInnerCommand && isCall) { SetVariables(innerCommand.GetVariables()); if (innerCommand.Next()) { return innerCommand.DoExecute(); } else { InnerCallFalse(); return executeCommand; } } else if (isInnerCommand && !isCall) { SetVariables(innerCommand.GetVariables()); if (innerCommand.Next()) { return innerCommand.DoExecute(); } else { innerCommand = null; isInnerCommand = false; return executeCommand; } } nowPosFlagName = offsetPos.ToString(); int length = conditionEnvironmentList.Size(); if (length > 0) { object ifResult = conditionEnvironmentList.Get(length - 1); if (ifResult != null) { backIfBool = (bool)(((Boolean)ifResult)); } } if (scriptList == null) { ResetCache(); return executeCommand; } else if (scriptList.Length - 1 < offsetPos) { ResetCache(); return executeCommand; } string cmd = scriptList[offsetPos]; if (cmd.StartsWith(RESET_CACHE_TAG)) { ResetCache(); return executeCommand; } if (isCache) { cacheCommandName = NowCacheOffsetName(cmd); object cache = CollectionUtils.Get(scriptContext, cacheCommandName); if (cache != null) { return (string)cache; } } if (flaging) { flaging = !(cmd.StartsWith(FLAG_LS_E_TAG) || cmd .EndsWith(FLAG_LS_E_TAG)); return executeCommand; } if (!flaging) { if (cmd.StartsWith(FLAG_LS_B_TAG) && !cmd.EndsWith(FLAG_LS_E_TAG)) { flaging = true; return executeCommand; } else if (cmd.StartsWith(FLAG_LS_B_TAG) && cmd.EndsWith(FLAG_LS_E_TAG)) { return executeCommand; } } SetupRandom(cmd); SetupSET(cmd); if (cmd.EndsWith(END_TAG)) { functioning = false; return executeCommand; } if (cmd.StartsWith(BEGIN_TAG)) { temps = CommandSplit(cmd); if (temps.Count == 2) { functioning = true; functions.Put(temps[1], new string[0]); return executeCommand; } } if (functioning) { int size = functions.Size() - 1; string[] function = (string[])functions.Get(size); int index = function.Length; function = (string[])CollectionUtils.Expand(function, 1); function[index] = cmd; functions.Set(size, function); return executeCommand; } if (((!esleflag && !ifing) || (esleflag && ifing)) && cmd.StartsWith(CALL_TAG) && !isCall) { temps = CommandSplit(cmd); if (temps.Count == 2) { string functionName = (string)temps[1]; string[] funs = (string[])functions.Get(functionName); if (funs != null) { innerCommand = new Command(scriptName + FLAG + functionName, funs); innerCommand.CloseCache(); innerCommand.SetVariables(GetVariables()); InnerCallTrue(); return null; } } } if (!if_bool && !elseif_bool) { if_bool = cmd.StartsWith(IF_TAG); elseif_bool = cmd.StartsWith(ELSE_TAG); } if (if_bool) { esleover = esleflag = SetupIF(cmd, nowPosFlagName, setEnvironmentList, conditionEnvironmentList); addCommand = false; ifing = true; } else if (elseif_bool) { string[] value_ren = StringUtils.Split(cmd, " "); if (!backIfBool && !esleflag) { if (value_ren.Length > 1 && IF_TAG.Equals(value_ren[1])) { esleover = esleflag = SetupIF( cmd.Replace(ELSE_TAG, "").Trim(), nowPosFlagName, setEnvironmentList, conditionEnvironmentList); addCommand = false; } else if (value_ren.Length == 1 && ELSE_TAG.Equals(value_ren[0])) { if (!esleover) { esleover = esleflag = SetupIF("if 1==1", nowPosFlagName, setEnvironmentList, conditionEnvironmentList); addCommand = false; } } } else { esleflag = false; addCommand = false; conditionEnvironmentList.Put(nowPosFlagName, (bool)(false)); } } if (cmd.StartsWith(IF_END_TAG)) { conditionEnvironmentList.Clear(); backIfBool = false; addCommand = false; ifing = false; if_bool = false; elseif_bool = false; esleover = false; return null; } if (backIfBool) { if (cmd.StartsWith(INCLUDE_TAG)) { if (IncludeCommand(cmd)) { return null; } } } else if (cmd.StartsWith(INCLUDE_TAG) && !ifing && !backIfBool && !esleflag) { if (IncludeCommand(cmd)) { return null; } } if (cmd.StartsWith(OUT_TAG)) { isRead = false; addCommand = false; executeCommand = (SELECTS_TAG + " " + readBuffer.ToString()); } if (isRead) { readBuffer.Append(cmd); readBuffer.Append(FLAG); addCommand = false; } if (cmd.StartsWith(IN_TAG)) { readBuffer.Remove(0, readBuffer.Length - (0)); isRead = true; return executeCommand; } if (addCommand && ifing) { if (backIfBool && esleflag) { executeCommand = cmd; } } else if (addCommand) { executeCommand = cmd; } if (cmd.StartsWith(FLAG_SAVE_TAG)) { temps = CommandSplit(cmd); if (temps != null && temps.Count == 2) { executeCommand = cmd; SaveCommand(null,null); return executeCommand; } } else if (cmd.StartsWith(FLAG_LOAD_TAG)) { temps = CommandSplit(cmd); if (temps != null && temps.Count == 2) { executeCommand = cmd; LoadCommand(null, -1); return executeCommand; } } if (executeCommand != null) { printTags = Command.GetNameTags(executeCommand, PRINT_TAG + BRACKET_LEFT_TAG, BRACKET_RIGHT_TAG); if (printTags != null) { for (IEnumerator it = printTags.GetEnumerator(); it.MoveNext(); ) { string key = (string)it.Current; object value_ren = CollectionUtils.Get(setEnvironmentList, key); if (value_ren != null) { executeCommand = StringUtils .ReplaceMatch( executeCommand, (PRINT_TAG + BRACKET_LEFT_TAG + key + BRACKET_RIGHT_TAG) , value_ren.ToString()); } else { executeCommand = StringUtils .ReplaceMatch( executeCommand, (PRINT_TAG + BRACKET_LEFT_TAG + key + BRACKET_RIGHT_TAG) , key); } } } if (isCache) { CollectionUtils.Put(scriptContext, cacheCommandName, executeCommand); } } } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { if (!isInnerCommand) { offsetPos++; } } return executeCommand; }
private void InnerCallFalse() { isCall = false; isInnerCommand = false; innerCommand = null; }
private bool IncludeCommand(string cmd) { temps = CommandSplit(cmd); StringBuilder sbr = new StringBuilder(); for (int i = 1; i < temps.Count; i++) { sbr.Append(temps[i]); } string fileName = sbr.ToString(); if (fileName.Length > 0) { innerCommand = new Command(fileName); isInnerCommand = true; return true; } return false; }
public override void InitCommandConfig(Command command) { // ��ʼ��ʱԤ����� command.SetVariable("p", "assets/p.png"); command.SetVariable("sel0", selects[0]); }