Exemple #1
0
        public override string Parse(string text)
        {
            if (UseNameParser && !string.IsNullOrEmpty(text))
            {
                NameParser   nameParser   = new NameParser(NameParserType);
                EscapeHelper escapeHelper = new EscapeHelper();
                escapeHelper.KeepEscapeCharacter = true;
                text = escapeHelper.Parse(text, nameParser.Parse);
            }

            return(base.Parse(text));
        }
Exemple #2
0
        public string Parse(string arg)
        {
            NameParser   nameParser   = new NameParser(NameParserType.Text);
            EscapeHelper escapeHelper = new EscapeHelper();

            escapeHelper.KeepEscapeCharacter = true;
            arg = escapeHelper.Parse(arg, nameParser.Parse);

            CustomUploaderParser customUploaderParser = new CustomUploaderParser(Filename, Input);

            arg = customUploaderParser.Parse(arg);

            return(arg);
        }
Exemple #3
0
        public string Parse(string arg)
        {
            NameParser   nameParser   = new NameParser(NameParserType.Text);
            EscapeHelper escapeHelper = new EscapeHelper();

            arg = escapeHelper.Parse(arg, nameParser.Parse);

            arg = arg.BatchReplace(new Dictionary <string, string>()
            {
                { "$filename$", Filename },
                { "$input$", Input }
            });

            return(arg);
        }
Exemple #4
0
        private string Parse(string text, bool isOutput)
        {
            if (string.IsNullOrEmpty(text))
            {
                return("");
            }

            if (UseNameParser)
            {
                NameParser   nameParser   = new NameParser(NameParserType);
                EscapeHelper escapeHelper = new EscapeHelper();
                escapeHelper.KeepEscapeCharacter = true;
                text = escapeHelper.Parse(text, nameParser.Parse);
            }

            StringBuilder sbResult      = new StringBuilder();
            StringBuilder sbSyntax      = new StringBuilder();
            bool          escapeNext    = false;
            bool          parsingSyntax = false;

            SyntaxInfoList = new List <CustomUploaderSyntaxInfo>();
            CustomUploaderSyntaxInfo syntaxInfo = null;

            for (int i = 0; i < text.Length; i++)
            {
                if (!escapeNext && text[i] == SyntaxChar)
                {
                    if (!parsingSyntax)
                    {
                        parsingSyntax = true;
                        sbSyntax.Clear();
                        syntaxInfo = new CustomUploaderSyntaxInfo()
                        {
                            StartPosition = i
                        };
                    }
                    else
                    {
                        parsingSyntax = false;
                        string syntax = sbSyntax.ToString();
                        EndSyntaxInfo(syntaxInfo, i, syntax);

                        if (!SkipSyntaxParse && !string.IsNullOrEmpty(syntax))
                        {
                            string syntaxResult = ParseSyntax(syntax, isOutput);

                            if (!string.IsNullOrEmpty(syntaxResult))
                            {
                                if (JSONEncode)
                                {
                                    syntaxResult = URLHelpers.JSONEncode(syntaxResult);
                                }
                                else if (XMLEncode)
                                {
                                    syntaxResult = URLHelpers.XMLEncode(syntaxResult);
                                }

                                sbResult.Append(syntaxResult);
                            }
                        }
                    }
                }
                else if (!escapeNext && text[i] == SyntaxEscapeChar)
                {
                    escapeNext = true;
                }
                else
                {
                    escapeNext = false;

                    if (!parsingSyntax)
                    {
                        sbResult.Append(text[i]);
                    }
                    else
                    {
                        sbSyntax.Append(text[i]);
                    }
                }
            }

            if (parsingSyntax)
            {
                string syntax = sbSyntax.ToString();
                EndSyntaxInfo(syntaxInfo, text.Length - 1, syntax);
            }

            return(sbResult.ToString());
        }