Пример #1
0
        /// <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());
        }
Пример #2
0
        /// <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());
        }
Пример #3
0
        /*
         * 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());
        }
Пример #4
0
        /// <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());
        }
Пример #5
0
        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());
        }
Пример #6
0
 private void WriteVarOrCap(BlockWriter writer)
 {
     if (!writer.CheckDefault(VariableName, nameof(VariableName)))
     {
         writer.Arrow()
         .Token(IsCapture ? "CAP" : "VAR")
         .Literal(VariableName);
     }
 }
Пример #7
0
        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());
        }
Пример #8
0
        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());
        }
Пример #9
0
        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());
        }
Пример #10
0
        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());
        }
Пример #11
0
        /// <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());
        }
Пример #12
0
        /// <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());
        }
Пример #13
0
        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());
        }
Пример #14
0
        /// <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());
        }
Пример #15
0
        /// <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());
        }
Пример #16
0
        /// <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());
        }