Example #1
1
        private string MacroElementEvaluator(Match m, bool toUnique, Item item, bool oldSyntax)
        {
            // Get the matched string.
            var element = m.ToString();
            var alias = "";

            if(oldSyntax)
                alias = getAttributeValue(m.ToString(), "macroAlias");
            else
                alias = getAttributeValue(m.ToString(), "alias");

            if (!string.IsNullOrEmpty(alias))
            {

                var attributesToReplace = MacroAttributesWithPicker(alias);

                if (this.RegisterMacroDependencies)
                    item.Dependencies.Add(alias, ItemProviders.ProviderIDCollection.macroItemProviderGuid);

                foreach (var attr in attributesToReplace)
                {
                    string regex = string.Format("(?<attributeAlias>{0})=\"(?<attributeValue>[^\"]*)\"", attr);
                    Regex rx = new Regex(regex, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
                    element = rx.Replace(element, match => MacroAttributeEvaluator(match, toUnique, item));
                }
            }
            return element;
        }
		/// <summary>
		/// Called to evaluate the HTML fragment corresponding to each 
		/// attribute's name/value in the code.
		/// </summary>
		/// <param name="match">The <see cref="Match"/> resulting from a 
		/// single regular expression match.</param>
		/// <returns>A string containing the HTML code fragment.</returns>
		private string AttributeMatchEval(Match match)
		{
			if(match.Groups[1].Success) //attribute value
				return "<span class=\"kwrd\">" + match.ToString() + "</span>";

			if(match.Groups[2].Success) //attribute name
				return "<span class=\"attr\">" + match.ToString() + "</span>";

			return match.ToString();
		}
Example #3
0
 /// <summary>
 /// Called to evaluate the HTML fragment corresponding to each 
 /// matching token in the code.
 /// </summary>
 /// <param name="match">The <see cref="Match"/> resulting from a 
 /// single regular expression match.</param>
 /// <returns>A string containing the HTML code fragment.</returns>
 protected override string MatchEval(Match match)
 {
     if (match.Groups[1].Success) //JavaScript code
     {
         //string s = match.ToString();
         return jsf.FormatSubCode(match.ToString());
     }
     if (match.Groups[2].Success) //comment
     {
         var reader = new StringReader(match.ToString());
         string line;
         var sb = new StringBuilder();
         while ((line = reader.ReadLine()) != null)
         {
             if (sb.Length > 0)
             {
                 sb.Append("\n");
             }
             sb.Append("<span class=\"rem\">");
             sb.Append(line);
             sb.Append("</span>");
         }
         return sb.ToString();
     }
     if (match.Groups[3].Success) //asp tag
     {
         return "<span class=\"asp\">" + match.ToString() + "</span>";
     }
     if (match.Groups[4].Success) //asp C# code
     {
         return csf.FormatSubCode(match.ToString());
     }
     if (match.Groups[5].Success) //tag delimiter
     {
         return "<span class=\"kwrd\">" + match.ToString() + "</span>";
     }
     if (match.Groups[6].Success) //html tagname
     {
         return "<span class=\"html\">" + match.ToString() + "</span>";
     }
     if (match.Groups[7].Success) //attributes
     {
         return attribRegex.Replace(match.ToString(),
             new MatchEvaluator(this.AttributeMatchEval));
     }
     if (match.Groups[8].Success) //entity
     {
         return "<span class=\"attr\">" + match.ToString() + "</span>";
     }
     return match.ToString();
 }
Example #4
0
            private static string JavaScriptMatch(Match _m)
            {

                if (_m.Groups[1].Success && !string.IsNullOrEmpty(_m.Groups[1].Value))
                    return _m.ToString().Replace(_m.Groups[1].Value, string.Format("/*<![CDATA[*/{0}/*]]>*/", new ScriptPacker(ScriptPacker.PackerEncoding.None, true, false).Pack(_m.Groups[1].Value)));
                return _m.ToString();
            }
Example #5
0
 internal override String Evaluate(Match match) {
   this.lastMatch = match;
   Object[] args = new Object[this.cArgs];
   if (this.cArgs > 0) {
     args[0] = match.ToString();
     if (this.cArgs > 1) {
       int i = 1;
       if (this.groupNumbers != null)
         for (; i <= this.groupNumbers.Length; i++) {
           Group group = match.Groups[this.groupNumbers[i-1]];
           args[i] = group.Success ? group.ToString() : null;
         }
       if (i < this.cArgs) {
         args[i++] = match.Index;
         if (i < this.cArgs) {
           args[i++] = this.source;
           for (; i < this.cArgs; i++)
             args[i] = null;
         }
       }
     }
   }
   Object result = this.function.Call(args, null);
   return match.Result(result is Empty ? "" : Convert.ToString(result));
 }
        private string LinkEvaluator(Match match)
        {
            var matchedString = match.ToString();
            var stringBuilder = new StringBuilder(matchedString);

            if(matchedString.Contains("|"))
            {
                var index = matchedString.IndexOf("|", StringComparison.Ordinal);
                matchedString = matchedString.Remove(index, stringBuilder.Length - index);
                stringBuilder.Remove(index, stringBuilder.Length - index);
            }

            if(matchedString.Contains(":"))
            {
                var index = matchedString.IndexOf(":", StringComparison.Ordinal);
                matchedString = matchedString.Remove(0, index);
                stringBuilder.Remove(0, index);
            }

            if(matchedString.Contains("#"))
            {
                var index = matchedString.IndexOf("#", StringComparison.Ordinal);
                //matchedString = matchedString.Remove(0, index);
                stringBuilder.Remove(0, index);
            }

            stringBuilder.Replace("[", string.Empty);
            stringBuilder.Replace("]", string.Empty);

            return stringBuilder.ToString();
        }
 protected virtual string PerformWebResourceSubstitution(Match match)
 {
     var replacedString = match.ToString();
     replacedString = replacedString.Replace(match.Value, ViewControl.Page.ClientScript.GetWebResourceUrl(
         this.GetType(), match.Groups["resourceName"].Value));
     return replacedString;
 }
Example #8
0
        private static string AddPerson(Match m)
        {
            string x = m.ToString();

            x = "<a href=" + HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + x.Trim('@') + ">" + x + "</a>";
            //x = "<a href=" + HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + x.Trim('@') + ">" + x + "</a>";
            return x;
        }
 private string Evaluator(Match match)
 {
     string replacement;
     if (_emoticonReplacementLookup.TryGetValue(match.Value, out replacement))
     {
         return string.Format(replacement, match.Value);
         }
     return match.ToString();
 }
 public virtual Token Match(string s)
 {
     if (this.pattern.IsMatch(s, 0))
     {
         System.Text.RegularExpressions.Match match = this.pattern.Match(s);
         return(this.BuildToken(match.ToString()));
     }
     return(null);
 }
Example #11
0
        private string EvaluateDefinedTerm(Match match)
        {
            var stringBuilder = new StringBuilder(match.ToString());

            stringBuilder.Replace(";", string.Empty);
            stringBuilder.Replace(":", string.Empty);
            stringBuilder.Append(".");

            return stringBuilder.ToString();
        }
Example #12
0
        private static string match(Match m)
        {
            string match = m.ToString();
            if (m_replaceDict.ContainsKey(match))
            {
                return m_replaceDict[match];
            }

            throw new NotSupportedException();
        }
Example #13
0
 static void Main(string[] args)
 {
     System.String testString2 = "!@Testing123_Blah123%$";
     System.Text.RegularExpressions.Regex testRegEx = new Regex("(\\w+)_(\\w+)");
     System.Text.RegularExpressions.Match testMatch = testRegEx.Match(testString2);
     Console.WriteLine(testMatch.Groups[1]);
     Console.WriteLine(testMatch.ToString());
     Console.WriteLine(testMatch.Length.ToString());
     Console.ReadLine();
 }
        private static string MutateUri(Match m)
        {
            var uri = m.ToString();

            if (uri.Length <= 1)
            {
                return uri;
            }

            return uri[1].ToString().ToUpper();
        }
Example #15
0
        private string EntryNumber(System.Text.RegularExpressions.Match match)
        {
            // expected number of letters
            string matchStr = match.ToString();

            if (matchStr.StartsWith("0"))
            {
                return("[^a-z]");
            }

            return("[a-z]{" + matchStr + "}");
        }
Example #16
0
 private static string ConvertMatchedDateToProperDateStamp(Match matchedDate)
 {
     string[] dateArray = Regex.Split(matchedDate.ToString(), "[-/]");
     string usDate = string.Empty;
     Debug.Assert(dateArray.Length <= 3);
     Boolean hasYear = dateArray.Length == 3;
     if (dateArray.Length < 3)
         usDate = dateArray[1] + "/" + dateArray[0] + "/" + DateTime.Now.Year.ToString();
     else
         usDate = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2];
     return usDate;
 }
Example #17
0
        private string EvaluateSection(Match match)
        {
            var stringBuilder = new StringBuilder(match.ToString());

            stringBuilder.Replace("=", string.Empty);

            var result = stringBuilder.ToString();
            result = result.TrimEnd(' ');
            result = result + ".";

            return result;
        }
Example #18
0
        private static string CapText(Match m)
        {
            //取得匹配的字符串
            string x = m.ToString();

            // 如果第一个字符是小写
            if (char.IsLower(x[0]))
                // 转换为大写
                return char.ToUpper(x[0]) + x.Substring(1, x.Length - 1);

            return x;
        }
Example #19
0
		/// <summary>
		/// Called to evaluate the HTML fragment corresponding to each 
		/// attribute's name/value in the code.
		/// </summary>
		/// <param name="match">The <see cref="Match"/> resulting from a 
		/// single regular expression match.</param>
		/// <returns>A string containing the HTML code fragment.</returns>
		protected override string MatchEval(Match match)
		{
            if (match.Groups[1].Success) //attribute value
                return "<span class=\"rem\">" + match.ToString() + "</span>";


			if(match.Groups[2].Success) //attribute value
				return "<span class=\"html\">" + match.ToString() + "</span>";

			if(match.Groups[3].Success) //attribute name
				return "<span class=\"attr\">" + match.ToString() + "</span>";

            if (match.Groups[4].Success) //close tag
                return "<span class=\"html\">" + match.ToString() + "</span>";

            if (match.Groups[5].Success) //values
                return "<span class=\"kwrd\">" + match.ToString().Replace(";","") + "</span>;";


            return match.ToString();
		}
Example #20
0
 public static string CapText(Match m)
 {
     // Get the matched string.
     string x = m.ToString();
     // If the first char is lower case...
     if (char.IsLower(x[0]))
     {
         // Capitalize it.
         return char.ToUpper(x[0]) + x.Substring(1, x.Length - 1);
     }
     return x;
 }
Example #21
0
 private string parseSpecial(Match m)
 {
     string txt = m.ToString();
     switch (txt[1]) {
     case 'r':
     if (txt.Length > 4)
         return Costs.Get(txt.Substring(2, txt.Length - 3)).ToString();
     break;
     case 'n':
     return "\r\n";
     }
     return txt;
 }
        static string StringHref(Match m)
        {
            string str = m.ToString();
            var numbersFromString = new String(str.Where(x => x >= '0' && x <= '9').ToArray());
            var id = Int32.Parse(numbersFromString);

            string[] words = str.Split('_');
            string type = words[1];
            string name = words[2];

            str = type + "=\"<ph id=\"" + id + "\" ctype=\"x-param\">" + "%" + name + "%</ph>";
            return str;
        }
        static string StringReplaceHref(Match m)
        {
            string str = m.ToString();
            var numbersFromString = new String(str.Where(x => x >= '0' && x <= '9').ToArray());
            var id = Int32.Parse(numbersFromString);

            string regex = "%\\w*%";
            Match findStringBetwween = Regex.Match(str, regex);
            string name = findStringBetwween.ToString();
            name = name.Substring(1, name.Length - 2);

            str = "\"jonckers_href_" + name + "_" + id;
            return str;
        }
Example #24
0
        /// <summary>
        /// Finner alle funksjoner som en bestemt variabel inngår i, og variabelens tilhørende beskrivelse. Hentes fra en C# xml fil.
        /// Dobbelarrayen har to kolonner. Første kolonne er funksjonsnavn, mens andre kolonne er variabelbeskrivelsen for hver funksjon.
        /// </summary>
        /// <param name="varNavn">Navnet på variabelen man vil ha info om.</param>
        /// <param name="fil">Full path med filnavn til xml filen.</param>
        /// <returns>Dobbelarrayen har to kolonner. Første kolonne er funksjonsnavn, mens andre kolonne er variabelbeskrivelsen for hver funksjon.</returns>
        public static string[,] XmlLesFunkNavnVarBeskFraVar(string varNavn, string fil)
        {
            Xml.XmlTextReader rd = new Xml.XmlTextReader(fil);
            System.Collections.Generic.List <string> varBeskLi  = new System.Collections.Generic.List <string>();
            System.Collections.Generic.List <string> funkNavnLi = new System.Collections.Generic.List <string>();
            string reg = "([.]\\w+([(]))"; //matcher punktum, etterfulgt av et ord, etterfulgt av parentesstart.

            while (rd.Read())
            {
                if (rd.Name == "member")
                { //Funksjonsnavn
                    string attr = "";
                    for (int j = 0; j < rd.AttributeCount; j++)
                    {
                        attr = rd.GetAttribute(0);                                         //Hvis jeg ikke har med for-løkken, så får jeg en feilmelding.
                    }
                    RegExp.Match m = RegExp.Regex.Match(attr, reg);
                    if (m.Success)
                    {
                        attr = m.ToString();
                        funkNavnLi.Add(attr.Remove(attr.Length - 1).Remove(0, 1)); //Fjerner punktum og parentes
                    }
                }
                else if (rd.Name == "param")
                { //Variabelbeskrivelse
                    string attr = "";
                    if (rd.AttributeCount > 0)
                    {
                        attr = rd.GetAttribute(0).Trim();                        //Det hender at rd ikke har noen attributes.
                    }
                    if (attr == varNavn)
                    {
                        varBeskLi.Add(rd.ReadString().Trim());
                    }
                }
            }
            rd.Close();
            if (string.IsNullOrEmpty(funkNavnLi[0]))
            {
                Console.WriteLine("Fant ikke variabelen " + varNavn + " i xmlfilen.");
                return(null);
            }
            string[,] funkNavnVarBeskLi = new string[funkNavnLi.Count, 2];
            for (int i = 0; i < funkNavnVarBeskLi.GetLength(0); i++)
            {
                funkNavnVarBeskLi[i, 0] = funkNavnLi[i];
                funkNavnVarBeskLi[i, 1] = varBeskLi[i];
            }
            return(funkNavnVarBeskLi);
        }
            public string ExtractResourceDictionary(Match m)
            {
                string matchedString = m.ToString();
                //<ResourceDictionary Source="Basic_Resources.xaml" />
                int start = matchedString.IndexOf("\"", StringComparison.Ordinal);
                    start = start + 1;
                if (start > 0)
                {
                    int end = matchedString.IndexOf("\"", start, StringComparison.Ordinal);
                    if (end > 0)
                    {
                        string file = matchedString.Substring(start, end - start);
                        if (!string.IsNullOrWhiteSpace(file))
                            ResourceDictionaryNames.Add(file);
                    }

                }
                return string.Empty;
            }
            public string MatchEvaluator(Match m)
            {
                if (m.Groups["content"].Length == 0)
                {
                    // It's possible that the "atts" match groups eats the contents
                    // when the user didn't want to give block attributes, but the content
                    // happens to match the syntax. For example: "*(blah)*".
                    if (m.Groups["atts"].Length == 0)
                        return m.ToString();
                    return "<" + m_tag + ">" + m.Groups["atts"].Value + m.Groups["end"].Value + "</" + m_tag + ">";
                }

                string atts = BlockAttributesParser.ParseBlockAttributes(m.Groups["atts"].Value, "");
                if (m.Groups["cite"].Length > 0)
                    atts += " cite=\"" + m.Groups["cite"] + "\"";

                string res = "<" + m_tag + atts + ">" +
                             m.Groups["content"].Value + m.Groups["end"].Value +
                             "</" + m_tag + ">";
                return res;
            }
Example #27
0
		private string MatchEvent(Match match)
		{
			string m = match.ToString();
			if (m == "\0")
				return "\\0";
			else if (m == "\a")
				return "\\a";
			else if (m == "\b")
				return "\\b";
			else if (m == "\f")
				return "\\f";
			else if (m == "\n")
				return "\\n";
			else if (m == "\r")
				return "\\r";
			else if (m == "\t")
				return "\\t";
			else if (m == "\v")
				return "\\v";
			else
				return m;
		}
 internal override string Evaluate(Match match)
 {
     base.lastMatch = match;
     object[] args = new object[this.cArgs];
     if (this.cArgs > 0)
     {
         args[0] = match.ToString();
         if (this.cArgs > 1)
         {
             int index = 1;
             if (this.groupNumbers != null)
             {
                 while (index <= this.groupNumbers.Length)
                 {
                     Group group = match.Groups[this.groupNumbers[index - 1]];
                     args[index] = group.Success ? group.ToString() : null;
                     index++;
                 }
             }
             if (index < this.cArgs)
             {
                 args[index++] = match.Index;
                 if (index < this.cArgs)
                 {
                     args[index++] = this.source;
                     while (index < this.cArgs)
                     {
                         args[index] = null;
                         index++;
                     }
                 }
             }
         }
     }
     object obj2 = this.function.Call(args, null);
     return match.Result((obj2 is Microsoft.JScript.Empty) ? "" : Microsoft.JScript.Convert.ToString(obj2));
 }
    // Update is called once per frame
    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Input.GetMouseButton(0))
        {
            Debug.DrawRay(ray.origin, ray.direction * 100, Color.green);
            RaycastHit hit = new RaycastHit();
            Physics.Raycast(ray, out hit, 10000.0f);
            if (hit.collider == null)
            {
            }
            else
            {
                string cName = hit.collider.name;
                System.Text.RegularExpressions.Match toot = (Regex.Match(cName, @"\d+"));
                cName = toot.ToString();
                int poot = int.Parse(cName);
                poot = poot / 3;
                Debug.Log(poot);
                string doot = poot.ToString();
                Application.LoadLevel(doot);
                //int num = int.Parse(cName);
                //float num2 = num/3;
            }
        }

        if (Input.GetMouseButtonDown(2))
        {
            Camera.main.fieldOfView = Camera.main.fieldOfView - something;
        }
        if (Input.GetMouseButtonUp(2))
        {
            Camera.main.fieldOfView = Camera.main.fieldOfView + something;
        }
    }
Example #30
0
 /// <summary>
 /// Called to evaluate the HTML fragment corresponding to each 
 /// matching token in the code.
 /// </summary>
 /// <param name="match">The <see cref="Match"/> resulting from a 
 /// single regular expression match.</param>
 /// <returns>A string containing the HTML code fragment.</returns>
 protected override string MatchEval(Match match)
 {
     if(match.Groups[1].Success) //comment
     {
         var reader = new StringReader(match.ToString());
         string line;
         var sb = new StringBuilder();
         while ((line = reader.ReadLine()) != null)
         {
             if(sb.Length > 0)
             {
                 sb.Append("\n");
             }
             sb.Append("<span class=\"rem\">");
             sb.Append(line);
             sb.Append("</span>");
         }
         return sb.ToString();
     }
     if(match.Groups[2].Success) //string literal
     {
         return "<span class=\"str\">" + match.ToString() + "</span>";
     }
     if(match.Groups[3].Success) //preprocessor keyword
     {
         return "<span class=\"preproc\">" + match.ToString() + "</span>";
     }
     if(match.Groups[4].Success) //keyword
     {
         return "<span class=\"kwrd\">" + match.ToString() + "</span>";
     }
     System.Diagnostics.Debug.Assert(false, "None of the above!");
     return ""; //none of the above
 }
Example #31
0
        private void createTask(enTaskType type)
        {
            saveCaretPosition();
            string selectedLineText = getSelectedLineText();

            System.Text.RegularExpressions.Match match = FindActionItemPatternInText(selectedLineText);
            if (match.Captures.Count > 0)
            {
                MessageBox.Show(string.Format("This line is already attached with Action Item: '{0}'", match.ToString()), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            StartOfLineCommand startOfLineCommand = new StartOfLineCommand(richEditControl1);

            startOfLineCommand.Execute();
            DocumentPosition beginOfLine = richEditControl1.Document.CaretPosition;

            //create task
            TaskForm newTaskForm = new TaskForm(_parent, new Tasks()
            {
                taskName = selectedLineText.Substring(0, Math.Min(128, selectedLineText.Length)), remarks = selectedLineText, updateRequester = false, projectID = Guid.Parse("00000000-0000-0000-0000-000000000000"), requesterID = Guid.Parse("00000000-0000-0000-0000-000000000000")
            }, formMode.add, type);

            _parent.openTaskForm(newTaskForm);

            if (newTaskForm.DialogResult == DialogResult.OK)
            {
                using (var model = new DocumentModel())
                {
                    string aiCaption = addActionItemText(beginOfLine, newTaskForm._task.ID, newTaskForm._task.getUserName());
                    startOfLineCommand.Execute(); //Go back to begining of line and make the inserted text as hyperlink
                    ChangeTextToHyperlink(aiCaption, newTaskForm._task.ID);
                    SaveMeetingRTF();
                }

                //DocumentImageCollection dic = richEditControl1.Document.GetImages(richEditControl1.Document.Range);

                syncActionItems();
            }
        }
Example #32
0
        private static string ConvertWindown1525ToUnicode(System.Text.RegularExpressions.Match match)
        {
            var c = match.ToString();

            return(c.Replace(c, DicChar[c]));
        }
        private string ConfluenceImage(Match match)
        {
            var str = match.ToString();
            if (match.Success)
            {
                var srcGroup = match.Groups["src"];
                var baseurlGroup = match.Groups["baseurl"];
                if (srcGroup.Success && baseurlGroup.Success)
                {
                    var url = baseurlGroup.Value;
                    if (url.LastIndexOf(WikiPrefix, StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        url = url.Substring(0, url.Length - WikiPrefix.Length);
                    }
                    url = url + srcGroup.Value;

                    return str.Replace(srcGroup.Value, url);
                }
            }

            return str;
        }
 /// <summary>
 /// Evaluates whether the text has spaces, page breaks, etc. and removes them.
 /// </summary>
 /// <param name="Matcher">Match found</param>
 /// <returns>The string minus any extra white space</returns>
 protected static string Evaluate(Match Matcher)
 {
     string MyString = Matcher.ToString();
     MyString = Regex.Replace(MyString, @"\r\n\s*", "");
     return MyString;
 }
        /// <summary>
        /// Strip any existing ImageResizer height and width parameters from the querystring 
        /// and add new ones derived from the img height and width attributes
        /// </summary>
        private static string ReplaceSrc(Match match, string height, string width, string quality)
        {
            // either "src" or "data-src"
            var attr = match.Groups[1].Value;

            string path = match.Groups[2].Value;
            if (string.IsNullOrWhiteSpace(path))
                return match.ToString();


            var parts = path.Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries);
            string url = parts.Length > 0 ? parts[0] : null;

            // ignore svg etc
            if (string.IsNullOrWhiteSpace(url) || url.StartsWith("data:", StringComparison.InvariantCultureIgnoreCase))
                return match.ToString();

            var ext = Path.GetExtension(path); //.ToLowerInvariant();
            if (string.IsNullOrWhiteSpace(ext))
                return match.ToString();

            // ignore files according to settings
            if ((!convertJpeg && (String.Compare(".jpg", ext) == 0 || String.Compare(".jpeg", ext) == 0))
                || (!convertTiff && (String.Compare(".tif", ext) == 0 || String.Compare(".tiff", ext) == 0))
                || (!convertPng && String.Compare(".png", ext) == 0)
                || (!convertBmp && String.Compare(".bmp", ext) == 0)
                || (!convertGif && String.Compare(".gif", ext) == 0)
                )
                return match.ToString();

            string qs = null;
            if (parts.Length == 2)
            {
                string qsEnc = parts[1];
                qs = qsEnc.Replace("&amp;", "&");
            }

            List<string> components = new List<string>();
            if (qs != null)
            {
                components = qs.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries)
                    .Where(i => !(
                        i.StartsWith("h=", StringComparison.InvariantCultureIgnoreCase) ||
                        i.StartsWith("w=", StringComparison.InvariantCultureIgnoreCase) ||
                        i.StartsWith("height=", StringComparison.InvariantCultureIgnoreCase) ||
                        i.StartsWith("width=", StringComparison.InvariantCultureIgnoreCase) ||
                        i.StartsWith("quality=", StringComparison.InvariantCultureIgnoreCase)))
                    .ToList();
            }
            if (height != null)
                components.Add("height=" + height);
            if (width != null)
                components.Add("width=" + width);
            if (!components.Any(c => c.StartsWith("quality=")) && quality != null)
                components.Add("quality=" + quality);
            if (!components.Any(c => c.StartsWith("format=")) && ext != ".jpg" && ext != ".jpeg")
                components.Add("format=jpg");
            qs = string.Join("&", components);

            // Azure blob storage strings must be 'redirected' to a relative url for them to be processed by image resizer
            // assuming resizer is running on the same url as the website
            if (url.StartsWith("http") && url.Contains("blob.core.windows.net"))
            {
                var index = url.IndexOf("//") + 2;
                index = url.IndexOf('/', index);
                url = url.Substring(index);
            }

            if (string.IsNullOrWhiteSpace(qs))
                return " " + attr + "='" + url + "'";
            else
                return " " + attr + "='" + url + "?" + qs + "'";
        }
Example #36
0
 private string GetSource(Match match)
 {
     var index = int.Parse(match.Groups[1].Value);
     return index < SourceFiles.Count ? string.Format("ERROR: {0}:", SourceFiles[index]) : match.ToString();
 }
 private static string Evaluate(Match Matcher)
 {
     Contract.Requires<ArgumentNullException>(Matcher != null, "Matcher");
     string MyString = Matcher.ToString();
     if (string.IsNullOrEmpty(MyString))
         return "";
     MyString = Regex.Replace(MyString, @"\r\n\s*", "");
     return MyString;
 }