public override bool ToBool() { string file = RuntimeVariables.GetInstance().GetValueString("this"); return(!FileValidator.IsDirectory(file)); }
public void Run() { RuntimeVariables.GetInstance().Add(name, value.ToString()); }
public override decimal ToNumber() { return(RuntimeVariables.GetInstance().GetValueNumber(name)); }
public void Run() { RuntimeVariables.GetInstance().MinusMinus(variable); }
public override string ToString() { string file = RuntimeVariables.GetInstance().GetValueString("this"); return(FileInnerVariable.GetFullname(file)); }
public override List <string> ToList() { List <string> result = elements.ToList(); foreach (ISubcommand subcom in subcommands) { if (subcom is Where) { string oldThis = RuntimeVariables.GetInstance().GetValueString("this"); List <string> newresult = new List <string>(); foreach (string s in result) { RuntimeVariables.GetInstance().Actualize("this", s); if ((subcom as Where).GetValue()) { newresult.Add(s); } } RuntimeVariables.GetInstance().Actualize("this", oldThis); result = newresult; } if (subcom is OrderBy) { result = OrderByExecutor.OrderBy(result, subcom as OrderBy); } if (subcom is With) { List <string> elementsFromSubcommands = (subcom as With).GetValue(); if ((subcom as With).IsNegated()) { //WITHOUT result.RemoveAll(v => (subcom as With).GetValue().Contains(v)); } else { //WITH result.AddRange((subcom as With).GetValue()); } } if (subcom is NumericSubcommand) { int number = (subcom as NumericSubcommand).GetValue(); switch ((subcom as NumericSubcommand).GetNumericSubcommandType()) { case NumericSubcommandType.First: { if (number <= 0) { return(new List <string>()); } else { if (number < result.Count) { result.RemoveRange(number, result.Count - number); } } break; } case NumericSubcommandType.Last: { if (number <= 0) { return(new List <string>()); } else { if (number < result.Count) { result.RemoveRange(0, result.Count - number); } } break; } case NumericSubcommandType.Skip: { if (number >= result.Count) { return(new List <string>()); } else { if (number > 0) { result.RemoveRange(0, number); } } break; } case NumericSubcommandType.Each: { if (number > 1) { List <string> newresult = new List <string>(); int c = 0; do { newresult.Add(result[c]); c += number; } while (c < result.Count); result = newresult; } break; } } } } return(result.ToList()); }
public override bool ToBool() { return(RuntimeVariables.GetInstance().GetValueBool(name)); }
public void PlaySinglePlayerButton() { RuntimeVariables.GetInstance().isSinglePlayerToggled = true; Application.LoadLevel("GameScene"); }
void Start() { RuntimeVariables.GetInstance().isSinglePlayerToggled = false; }
public override string ToString() { return(RuntimeVariables.GetInstance().GetListElement(name, (int)index.ToNumber())); }
public override List <string> ToList() { return(RuntimeVariables.GetInstance().GetValueList(name)); }
public void Run() { RuntimeVariables.GetInstance().SetElementAtIndex(name, value.ToString(), (int)index.ToNumber()); }
public void Run() { RuntimeVariables.GetInstance().PlusPlus(variable); }
protected override void DirectoryAction(string movingDirectoryName, string rawLocation) { string directoryName = destination.ToString(); if (directoryName.Equals(movingDirectoryName)) { RuntimeVariables.GetInstance().Failure(); throw new CommandException("Action ignored! Directory " + directoryName + " cannot be copied to itself."); } if (!FileValidator.IsNameCorrect(directoryName)) { RuntimeVariables.GetInstance().Failure(); throw new CommandException("Action ignored! " + directoryName + " contains not allowed characters."); } string newMovingDirectoryName = newName.ToString(); if (!FileValidator.IsNameCorrect(newMovingDirectoryName)) { RuntimeVariables.GetInstance().Failure(); throw new CommandException("Action ignored! " + newMovingDirectoryName + " contains not allowed characters."); } if (!FileValidator.IsDirectory(newMovingDirectoryName)) { RuntimeVariables.GetInstance().Failure(); throw new CommandException("Action ignored! " + newMovingDirectoryName + " is not allowed name for directory."); } string oldLocation = rawLocation + "//" + movingDirectoryName; string newLocation = rawLocation + "//" + directoryName + "//" + newMovingDirectoryName; if (!Directory.Exists(rawLocation + "//" + directoryName)) { Directory.CreateDirectory(rawLocation + "//" + directoryName); } if (!Directory.Exists(rawLocation + "//" + directoryName + "//" + newMovingDirectoryName)) { Directory.CreateDirectory(rawLocation + "//" + directoryName + "//" + newMovingDirectoryName); } try { if (forced && Directory.Exists(newLocation)) { Directory.Delete(@newLocation, true); } DirectoryCopy(@oldLocation, @newLocation); RuntimeVariables.GetInstance().Success(); Logger.GetInstance().LogCommand("Copy " + movingDirectoryName + " to " + directoryName + " as " + newMovingDirectoryName); } catch (Exception ex) { RuntimeVariables.GetInstance().Failure(); if (ex is IOException || ex is UnauthorizedAccessException) { throw new CommandException("Action ignored! Access denied during coping " + movingDirectoryName + " to " + directoryName + " as " + newMovingDirectoryName + "."); } else { throw new CommandException("Action ignored! Something went wrong during coping " + movingDirectoryName + " to " + directoryName + " as " + newMovingDirectoryName + "."); } } }
public void Run() { RuntimeVariables.GetInstance().Swap(leftName, rightName); }
protected override void FileAction(string fileName, string newLocation) { RuntimeVariables.GetInstance().Failure(); throw new CommandException("Action ignored! Name for directory " + fileName + " is not suitable."); }
public static void RunCommands(List <ICommand> commands) { List <Structure> structures = new List <Structure>(); bool jumpIntoElse = false; try { int pointer = 0; while (pointer < commands.Count()) { ICommand takenCommand = commands[pointer]; if (takenCommand is BracketOn) { RuntimeVariables.GetInstance().BracketsUp(); if (takenCommand is EmptyOpenning) { structures.Add(new EmptyBlock()); } else if (takenCommand is IfOpenning) { if (jumpIntoElse) { jumpIntoElse = false; } if ((takenCommand as IfOpenning).ToBool()) { structures.Add(new If()); } else { pointer = JumpOverBlockOfCode(commands, pointer); jumpIntoElse = true; } } else if (takenCommand is ElseOpenning) { if (jumpIntoElse) { structures.Add(new Else()); jumpIntoElse = false; } else { pointer = JumpOverBlockOfCode(commands, pointer); } } else if (takenCommand is WhileOpenning) { if ((takenCommand as WhileOpenning).ToBool()) { structures.Add(new While((takenCommand as WhileOpenning).GetCondition(), (takenCommand as BracketOn).GetCommandNumber())); } else { pointer = JumpOverBlockOfCode(commands, pointer); } if (jumpIntoElse) { jumpIntoElse = false; } } else if (takenCommand is InsideOpenning) { List <string> list = (takenCommand as InsideOpenning).ToList(); if (list.Count == 0) { pointer = JumpOverBlockOfCode(commands, pointer); } else { string value = list[0]; list.RemoveAt(0); structures.Add(new Inside(list, (takenCommand as BracketOn).GetCommandNumber())); RuntimeVariables.GetInstance().Actualize("this", value); RuntimeVariables.GetInstance().ExpandLocation(value); RuntimeVariables.GetInstance().Actualize("index", 0); } if (jumpIntoElse) { jumpIntoElse = false; } } else if (takenCommand is ListLoopOpenning) { List <string> list = (takenCommand as ListLoopOpenning).ToList(); if (list.Count == 0) { pointer = JumpOverBlockOfCode(commands, pointer); } else { string value = list[0]; list.RemoveAt(0); structures.Add(new ListLoop(list, (takenCommand as BracketOn).GetCommandNumber())); RuntimeVariables.GetInstance().Actualize("this", value); RuntimeVariables.GetInstance().Actualize("index", 0); } if (jumpIntoElse) { jumpIntoElse = false; } } else if (takenCommand is NumericLoopOpenning) { int repeats = (int)(takenCommand as NumericLoopOpenning).ToNumber(); if (repeats <= 0) { pointer = JumpOverBlockOfCode(commands, pointer); } else { repeats--; structures.Add(new NumericLoop(repeats, (takenCommand as BracketOn).GetCommandNumber())); RuntimeVariables.GetInstance().Actualize("index", 0); } if (jumpIntoElse) { jumpIntoElse = false; } } } else if (takenCommand is BracketOff) { RuntimeVariables.GetInstance().BracketsDown(); if (structures.Count == 0) { throw new RuntimeException("ERROR! Brackets are wrong."); } Structure lastStructure = structures.Last(); if (lastStructure is ILoopingStructure) { bool iterateOneMoreTime = lastStructure.HasNext(); if (iterateOneMoreTime) { pointer = lastStructure.GetCommandNumber(); RuntimeVariables.GetInstance().BracketsUp(); } else { structures.RemoveAt(structures.Count - 1); } } else { structures.RemoveAt(structures.Count - 1); } } else { commands[pointer].Run(); } pointer++; } } catch (Uroboros.syntax.RuntimeException re) { Logger.GetInstance().LogRuntimeError(re.GetMessage()); } }
public override decimal ToNumber() { string file = RuntimeVariables.GetInstance().GetValueString("this"); return(FileInnerVariable.GetSize(file)); }
public override bool ToBool() { string file = RuntimeVariables.GetInstance().GetValueString("this"); return(FileInnerVariable.Exist(file)); }
public override DateTime ToTime() { return(RuntimeVariables.GetInstance().GetValueTime(name)); }
protected override void DirectoryAction(string directoryName, string location) { RuntimeVariables.GetInstance().Failure(); throw new CommandException("Action ignored! Name for file " + directoryName + " is not suitable."); }
public override string ToString() { return(RuntimeVariables.GetInstance().GetPath()); }
public void Run() { RuntimeVariables.GetInstance().Actualize(name, value.ToTime()); }
public void Run() { RuntimeVariables.GetInstance().DivideBy(variable, value.ToNumber()); }
public void Run() { RuntimeVariables.GetInstance().Reverse(name); }
public void Run() { RuntimeVariables.GetInstance().Add(name, values.ToList()); }
public void Run() { RuntimeVariables.GetInstance().IncrementBy(variable, value.ToNumber()); }
public override string ToString() { return(RuntimeVariables.GetInstance().GetValueString(name)); }