/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("PARSE") .Literal(ParseTarget) .Token(Type); switch (Type) { case ParseType.LR: writer .Literal(LeftString) .Literal(RightString) .Boolean(Recursive, "Recursive") .Boolean(UseRegexLR, "UseRegexLR"); break; case ParseType.CSS: writer .Literal(CssSelector) .Literal(AttributeName); if (Recursive) { writer.Boolean(Recursive, "Recursive"); } else { writer.Integer(CssElementIndex, "CssElementIndex"); } break; case ParseType.JSON: writer .Literal(JsonField) .Boolean(Recursive, "Recursive"); break; case ParseType.REGEX: writer .Literal(RegexString) .Literal(RegexOutput) .Boolean(Recursive, "Recursive"); break; } writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); if (!writer.CheckDefault(Prefix, "Prefix") || !writer.CheckDefault(Suffix, "Suffix")) { writer.Literal(Prefix).Literal(Suffix); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("ELEMENTACTION") .Token(Locator) .Literal(ElementString); if (Recursive) { writer.Boolean(Recursive, "Recursive"); } else if (ElementIndex != 0) { writer.Integer(ElementIndex, "ElementIndex"); } writer .Indent() .Token(Action) .Literal(Input, "Input"); if (!writer.CheckDefault(OutputVariable, "OutputVariable")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(OutputVariable); } return(writer.ToString()); }
public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled) .Label(Label) // Write the label. If the label is the default one, nothing is written. .Token(Name) // Write the block name. This cannot be changed. .Literal(awshost) .Literal(awspath) .Literal(awsregion) .Literal(awscredential) .Literal(awskey) .Literal(awssecretkey) .Literal(awssession) .Literal(awshttpmethod) .Literal(awsbodydata) .Literal(awscustomheader); if (!writer.CheckDefault(VariableName, nameof(VariableName))) { writer .Arrow() // Write the -> arrow. .Token(IsCapture ? "CAP" : "VAR") // Write CAP or VAR depending on IsCapture. .Literal(VariableName); // Write the Variable Name as a literal. } return(writer.ToString()); }
/* * This method basically does the opposite of the method above, so it converts a Block from a class to an actual * LoliScript statement. It's much easier to write since the BlockWriter was implemented with a fluent pattern. */ public override string ToLS(bool indent = true) { /* * We initialize a new BlockWriter with the given Block type (in this case, GetType() will return BlockSum) * and indentation enabled by default when needed (you can type .Indent() anywhere to indent to the next line). * The Disabled parameter will tell the writer if the block has been disabled. In that case, it will put a '!' * in front of the statement to indicate that it shouldn't be executed by a debugger or runner. */ var writer = new BlockWriter(GetType(), indent, Disabled) .Label(Label) // Write the label. If the label is the default one, nothing is written. .Token(Name) // Write the block name. This cannot be changed. .Literal(First) // Write the 'First' parameter as a literal (it will be double quoted). .Literal(Second); // Write the 'Second' parameter as a literal. // Check if the VariableName is the default one. If it is, we don't need to write it to the string. if (!writer.CheckDefault(VariableName, nameof(VariableName))) { // Here we reutilize the writer to write more stuff. writer .Arrow() // Write the -> arrow. .Token(IsCapture ? "CAP" : "VAR") // Write CAP or VAR depending on IsCapture. .Literal(VariableName); // Write the Variable Name as a literal. } // Finally we call the ToString() method of the writer to return the statement that will be written to the LoliScript code. return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("TCP") .Token(TCPCommand); switch (TCPCommand) { case TCPCommand.Connect: writer .Literal(Host) .Literal(Port) .Boolean(UseSSL, "UseSSL"); break; case TCPCommand.Send: writer .Literal(Message); break; } if (!writer.CheckDefault(VariableName, "VariableName")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); } return(writer.ToString()); }
private void WriteVarOrCap(BlockWriter writer) { if (!writer.CheckDefault(VariableName, nameof(VariableName))) { writer.Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); } }
public override string ToLS(bool indent = true) { BlockWriter blockWriter = new BlockWriter(base.GetType(), indent, base.Disabled).Label(base.Label).Token(this.Name, "").Literal(this.Email, "").Literal(this.Password, "").Integer(this.MaxFilesCaptured, ""); bool flag = !blockWriter.CheckDefault(this.VariableName, "VariableName"); if (flag) { blockWriter.Arrow().Token(this.IsCapture ? "CAP" : "VAR", "").Literal(this.VariableName, ""); } return(blockWriter.ToString()); }
public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled) .Label(Label) // Write the label. If the label is the default one, nothing is written. .Token(Name); // Write the block name. This cannot be changed. if (!writer.CheckDefault(VariableName, nameof(VariableName))) { writer .Arrow() // Write the -> arrow. .Token(IsCapture ? "CAP" : "VAR") // Write CAP or VAR depending on IsCapture. .Literal(VariableName); // Write the Variable Name as a literal. } return(writer.ToString()); }
public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer.Label(Label) .Token(nameof(McDonaldsCapReader)) .Literal(Base64Captcha); if (!writer.CheckDefault(InputVariableName, nameof(InputVariableName))) { writer.Arrow() .Token("VAR") .Literal(InputVariableName) .Indent(); } return(writer.ToString()); }
public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer.Label(Label) .Token(nameof(BCrypt)) .Literal(input) .Literal(Salt); if (!writer.CheckDefault(VariableName, nameof(VariableName))) { writer.Arrow() .Token("VAR") .Literal(VariableName) .Indent(); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("EXECUTEJS") .Literal(JavascriptCode.Replace("\r\n", " ").Replace("\n", " ")); if (!writer.CheckDefault(OutputVariable, "OutputVariable")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(OutputVariable); } return(writer.ToString()); }
/// <inheritdoc/> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer.Label(Label) .Token("SPEECHTOTEXT") .Token(Lang) .Literal(Url); if (!writer.CheckDefault(VariableName, nameof(VariableName))) { writer.Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName) .Indent(); } return(writer.ToString()); }
public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer.Label(Label) .Token(nameof(RecaptchaV3Bypass)) .Literal(RecaptchaUrlGet) .Literal(BG) .Literal(RecaptchaUrlPost); if (!writer.CheckDefault(VariableName, nameof(VariableName))) { writer.Arrow() .Token("VAR") .Literal(VariableName) .Indent(); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("FUNCTION") .Token(FunctionType); switch (FunctionType) { case Function.Hash: writer .Token(HashType); break; case Function.HMAC: writer .Token(HashType) .Literal(HmacKey) .Boolean(HmacBase64, "HmacBase64") .Boolean(KeyBase64, "KeyBase64"); break; case Function.Translate: writer .Boolean(StopAfterFirstMatch, "StopAfterFirstMatch"); foreach (var t in TranslationDictionary) { writer .Indent() .Token("KEY") .Literal(t.Key) .Token("VALUE") .Literal(t.Value); } writer .Indent(); break; case Function.UnixTimeToDate: case Function.DateToUnixTime: writer .Literal(DateFormat); break; case Function.Replace: writer .Literal(ReplaceWhat) .Literal(ReplaceWith) .Boolean(UseRegex, "UseRegex"); break; case Function.RegexMatch: writer .Literal(RegexMatch, "RegexMatch"); break; case Function.RandomNum: writer .Literal(RandomMin) .Literal(RandomMax) .Boolean(RandomZeroPad, "RandomZeroPad"); break; case Function.CountOccurrences: writer .Literal(StringToFind); break; case Function.CharAt: writer .Literal(CharIndex); break; case Function.Substring: writer .Literal(SubstringIndex) .Literal(SubstringLength); break; case Function.RSAEncrypt: writer .Literal(RsaN) .Literal(RsaE) .Boolean(RsaOAEP, "RsaOAEP"); break; /* * case Function.RSADecrypt: * writer * .Literal(RsaN) * .Literal(RsaD) * .Boolean(RsaOAEP, "RsaOAEP"); * break; */ case Function.RSAPKCS1PAD2: writer .Literal(RsaN) .Literal(RsaE); break; case Function.GetRandomUA: if (UserAgentSpecifyBrowser) { writer .Token("BROWSER") .Token(UserAgentBrowser); } break; case Function.AESDecrypt: case Function.AESEncrypt: writer .Literal(AesKey) .Literal(AesIV) .Token(AesMode) .Token(AesPadding); break; case Function.PBKDF2PKCS5: if (KdfSalt != string.Empty) { writer.Literal(KdfSalt); } else { writer.Integer(KdfSaltSize); } writer .Integer(KdfIterations) .Integer(KdfKeySize) .Token(KdfAlgorithm); break; } writer .Literal(InputString, "InputString"); if (!writer.CheckDefault(VariableName, "VariableName")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("REQUEST") .Token(Method) .Literal(Url) .Boolean(AutoRedirect, "AutoRedirect") .Boolean(ReadResponseSource, "ReadResponseSource") .Boolean(ParseQuery, "ParseQuery") .Boolean(EncodeContent, "EncodeContent") .Token(RequestType, "RequestType") .Indent(); switch (RequestType) { case RequestType.BasicAuth: writer .Token("USERNAME") .Literal(AuthUser) .Token("PASSWORD") .Literal(AuthPass) .Indent(); break; case RequestType.Standard: if (!writer.CheckDefault(PostData, "PostData")) { writer .Token("CONTENT") .Literal(PostData) .Indent() .Token("CONTENTTYPE") .Literal(ContentType); } break; case RequestType.Multipart: foreach (var c in MultipartContents) { writer .Indent() .Token($"{c.Type.ToString().ToUpper()}CONTENT") .Literal($"{c.Name}: {c.Value}"); } if (!writer.CheckDefault(MultipartBoundary, "MultipartBoundary")) { writer .Indent() .Token("BOUNDARY") .Literal(MultipartBoundary); } break; } foreach (var c in CustomCookies) { writer .Indent() .Token("COOKIE") .Literal($"{c.Key}: {c.Value}"); } foreach (var h in CustomHeaders) { writer .Indent() .Token("HEADER") .Literal($"{h.Key}: {h.Value}"); } if (ResponseType == ResponseType.File) { writer .Indent() .Arrow() .Token("FILE") .Literal(DownloadPath); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("UTILITY") .Token(Group); switch (Group) { case UtilityGroup.List: writer .Literal(ListName) .Token(ListAction); switch (ListAction) { case ListAction.Join: writer .Literal(Separator); break; case ListAction.Sort: writer .Boolean(Ascending, "Ascending") .Boolean(Numeric, "Numeric"); break; case ListAction.Concat: case ListAction.Zip: case ListAction.Map: writer .Literal(SecondListName); break; case ListAction.Add: writer .Literal(ListItem) .Literal(ListIndex); break; case ListAction.Remove: writer .Literal(ListIndex); break; case ListAction.RemoveValues: writer .Token(ListElementComparer) .Literal(ListComparisonTerm); break; } break; case UtilityGroup.Variable: writer .Literal(VarName) .Token(VarAction); switch (VarAction) { case VarAction.Split: writer .Literal(SplitSeparator); break; } break; case UtilityGroup.Conversion: writer .Token(ConversionFrom) .Token(ConversionTo) .Literal(InputString); break; case UtilityGroup.File: writer .Literal(FilePath) .Token(FileAction); switch (FileAction) { case FileAction.Write: case FileAction.WriteLines: case FileAction.Append: case FileAction.AppendLines: case FileAction.Copy: case FileAction.Move: writer .Literal(InputString); break; } break; case UtilityGroup.Folder: writer .Literal(FolderPath) .Token(FolderAction); break; } if (!writer.CheckDefault(VariableName, "VariableName")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("FUNCTION") .Token(FunctionType); switch (FunctionType) { case Function.Hash: writer .Token(HashType); break; case Function.HMAC: writer .Token(HashType) .Literal(HmacKey) .Boolean(HmacBase64, "HmacBase64"); break; case Function.Translate: writer .Boolean(StopAfterFirstMatch, "StopAfterFirstMatch"); foreach (var t in TranslationDictionary) { writer .Indent() .Token("KEY") .Literal(t.Key) .Token("VALUE") .Literal(t.Value); } writer .Indent(); break; case Function.DateToUnixTime: writer .Literal(DateFormat, "DateFormat"); break; case Function.Replace: writer .Literal(ReplaceWhat) .Literal(ReplaceWith) .Boolean(UseRegex, "UseRegex"); break; case Function.RegexMatch: writer .Literal(RegexMatch, "RegexMatch"); break; case Function.RandomNum: writer .Integer(RandomMin) .Integer(RandomMax); break; case Function.CountOccurrences: writer .Literal(StringToFind); break; case Function.CharAt: writer .Literal(CharIndex); break; case Function.Substring: writer .Literal(SubstringIndex) .Literal(SubstringLength); break; case Function.RSA: writer .Literal(RSAMod) .Literal(RSAExp); break; } writer .Literal(InputString, "InputString"); if (!writer.CheckDefault(VariableName, "VariableName")) { writer .Arrow() .Token(IsCapture ? "CAP" : "VAR") .Literal(VariableName); } return(writer.ToString()); }
/// <inheritdoc /> public override string ToLS(bool indent = true) { var writer = new BlockWriter(GetType(), indent, Disabled); writer .Label(Label) .Token("REQUEST") .Token(Method) .Literal(Url) .Boolean(AcceptEncoding, "AcceptEncoding") .Boolean(AutoRedirect, "AutoRedirect") .Boolean(ReadResponseSource, "ReadResponseSource") .Boolean(EncodeContent, "EncodeContent") .Token(RequestType, "RequestType") .Indent(); switch (RequestType) { case RequestType.BasicAuth: writer .Token("USERNAME") .Literal(AuthUser) .Token("PASSWORD") .Literal(AuthPass) .Indent(); break; case RequestType.Standard: if (HttpRequest.CanContainRequestBody(method)) { writer .Token("CONTENT") .Literal(PostData) .Indent() .Token("CONTENTTYPE") .Literal(ContentType); } break; case RequestType.Multipart: foreach (var c in MultipartContents) { writer .Indent() .Token($"{c.Type.ToString().ToUpper()}CONTENT"); if (c.Type == MultipartContentType.String) { writer.Literal($"{c.Name}: {c.Value}"); } else if (c.Type == MultipartContentType.File) { writer.Literal($"{c.Name}: {c.Value}: {c.ContentType}"); } } if (!writer.CheckDefault(MultipartBoundary, "MultipartBoundary")) { writer .Indent() .Token("BOUNDARY") .Literal(MultipartBoundary); } break; case RequestType.Raw: if (HttpRequest.CanContainRequestBody(method)) { writer .Token("RAWDATA") .Literal(RawData) .Indent() .Token("CONTENTTYPE") .Literal(ContentType); } break; } if (SecurityProtocol != SecurityProtocol.SystemDefault) { writer .Indent() .Token("SECPROTO") .Token(SecurityProtocol, "SecurityProtocol"); } foreach (var c in CustomCookies) { writer .Indent() .Token("COOKIE") .Literal($"{c.Key}: {c.Value}"); } foreach (var h in CustomHeaders) { writer .Indent() .Token("HEADER") .Literal($"{h.Key}: {h.Value}"); } if (ResponseType == ResponseType.File) { writer .Indent() .Arrow() .Token("FILE") .Literal(DownloadPath) .Boolean(SaveAsScreenshot, "SaveAsScreenshot"); } else if (ResponseType == ResponseType.Base64String) { writer .Indent() .Arrow() .Token("BASE64") .Literal(OutputVariable); } return(writer.ToString()); }