public override bool Run() { string _text = Contents; if (KScriptBoolHandler.Convert(trim)) { _text = _text.Trim(); } if (type == "paragraph") { _text = KScriptParagraphHandler.Parse(_text); } Out(_text); Out(Environment.NewLine, () => { return(!string.IsNullOrEmpty(trail_newline) && KScriptBoolHandler.Convert(trail_newline)); }); return(true); }
/// <summary> /// Checks for existing array or def with specified ID. /// If ExpectedInput type is custom, will not be validated. Must be overriden. /// </summary> /// <param name="container">KScriptContainer object</param> /// <param name="caller">Object calling method</param> /// <returns>If the check was successfull</returns> public bool IsExpectedInput(KScriptContainer container, KScriptBaseObject caller) { ExpectedInput x = expected_input; switch (x) { case ExpectedInput.ArrayID: string array_id = GetPropertyValue(caller); return(container.ArraysGet().ContainsKey(array_id)); case ExpectedInput.DefID: if (container.Properties.DynamicDefs) { return(true); } string def_id = GetPropertyValue(caller); return(container.GetDefs().ContainsKey(def_id)); case ExpectedInput.DirectoryLocation: string directory = GetPropertyValue(caller); return(Directory.Exists(directory)); case ExpectedInput.FileLocation: string file = GetPropertyValue(caller); return(File.Exists(file)); case ExpectedInput.URL: string url = GetPropertyValue(caller); return(Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out _)); case ExpectedInput.Number: return(int.TryParse(GetPropertyValue(caller), out _)); case ExpectedInput.Bool: bool isBool = KScriptBoolHandler.IsBool(GetPropertyValue(caller)); return(isBool); } return(true); }
public override string Evaluate(params string[] args) { return(ToBoolString(KScriptBoolHandler.IsBool(GetDef().Contents))); }
public bool IsBool(string @in) => KScriptBoolHandler.IsBool(@in);
/// <summary> /// Method to return string input to a bool. /// </summary> /// <param name="in">The string to convert to a bool.</param> /// <returns>Bool value.</returns> public bool ToBool(string @in) => KScriptBoolHandler.Convert(@in);