예제 #1
0
        public void ParseResponse(UploadResult result, CustomUploaderInput input, bool isShortenedURL = false)
        {
            if (result != null && !string.IsNullOrEmpty(result.Response))
            {
                CustomUploaderParser parser = new CustomUploaderParser(result.Response, RegexList);
                parser.Filename  = input.Filename;
                parser.URLEncode = true;

                string url;

                if (!string.IsNullOrEmpty(URL))
                {
                    url = parser.Parse(URL);
                }
                else
                {
                    url = parser.Response;
                }

                if (isShortenedURL)
                {
                    result.ShortenedURL = url;
                }
                else
                {
                    result.URL = url;
                }

                result.ThumbnailURL = parser.Parse(ThumbnailURL);
                result.DeletionURL  = parser.Parse(DeletionURL);
            }
        }
예제 #2
0
        private void CustomUploaderSyntaxHighlight(RichTextBox rtb)
        {
            if (!string.IsNullOrEmpty(rtb.Text))
            {
                CustomUploaderParser parser = new CustomUploaderParser();
                parser.SkipSyntaxParse = true;
                parser.Parse(rtb.Text);

                if (parser.SyntaxInfoList != null)
                {
                    int start  = rtb.SelectionStart;
                    int length = rtb.SelectionLength;
                    rtb.BeginUpdate();

                    rtb.SelectionStart  = 0;
                    rtb.SelectionLength = rtb.TextLength;
                    rtb.SelectionColor  = rtb.ForeColor;

                    foreach (CustomUploaderSyntaxInfo syntaxInfo in parser.SyntaxInfoList)
                    {
                        rtb.SelectionStart  = syntaxInfo.StartPosition;
                        rtb.SelectionLength = syntaxInfo.Length;
                        rtb.SelectionColor  = Color.Green;
                    }

                    rtb.SelectionStart  = start;
                    rtb.SelectionLength = length;
                    rtb.EndUpdate();
                }
            }
        }
예제 #3
0
        public string GetData(CustomUploaderInput input)
        {
            CustomUploaderParser parser = new CustomUploaderParser(input);

            parser.UseNameParser = true;
            parser.JSONEncode    = RequestFormat == CustomUploaderRequestFormat.JSON;

            return(parser.Parse(Data));
        }
예제 #4
0
        public string GetHttpHomePath()
        {
            string homePath = HttpHomePath.Replace("%host", Host);

            CustomUploaderParser parser = new CustomUploaderParser();

            parser.UseNameParser  = true;
            parser.NameParserType = NameParserType.URL;
            return(parser.Parse(homePath));
        }
예제 #5
0
        public string GetRequestURL()
        {
            if (string.IsNullOrEmpty(RequestURL))
            {
                throw new Exception(Resources.CustomUploaderItem_GetRequestURL_RequestURLMustBeConfigured);
            }

            CustomUploaderParser parser = new CustomUploaderParser();
            string url = parser.Parse(RequestURL);

            return(URLHelpers.FixPrefix(url));
        }
예제 #6
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);
        }
예제 #7
0
        public Dictionary <string, string> GetArguments(CustomUploaderInput input)
        {
            Dictionary <string, string> arguments = new Dictionary <string, string>();

            if (Arguments != null)
            {
                CustomUploaderParser parser = new CustomUploaderParser(input);
                parser.UseNameParser = true;

                foreach (KeyValuePair <string, string> arg in Arguments)
                {
                    arguments.Add(arg.Key, parser.Parse(arg.Value));
                }
            }

            return(arguments);
        }
예제 #8
0
        public NameValueCollection GetHeaders(CustomUploaderInput input)
        {
            if (Headers != null && Headers.Count > 0)
            {
                NameValueCollection  collection = new NameValueCollection();
                CustomUploaderParser parser     = new CustomUploaderParser(input);
                parser.UseNameParser = true;

                foreach (KeyValuePair <string, string> header in Headers)
                {
                    collection.Add(header.Key, parser.Parse(header.Value));
                }

                return(collection);
            }

            return(null);
        }