• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MatchEvaluator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MatchEvaluator的典型用法代码示例。如果您正苦于以下问题:C# MatchEvaluator类的具体用法?C# MatchEvaluator怎么用?C# MatchEvaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MatchEvaluator类属于命名空间,在下文中一共展示了MatchEvaluator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExecuteResult

 public override void ExecuteResult(ControllerContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (JsonRequestBehavior == JsonRequestBehavior.DenyGet &&
         String.Equals(context.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
     {
         throw new InvalidOperationException(error);
     }
     HttpResponseBase response = context.HttpContext.Response;
     if (!String.IsNullOrEmpty(ContentType))
     {
         response.ContentType = ContentType;
     }
     else
     {
         response.ContentType = "application/json";
     }
     if (ContentEncoding != null)
     {
         response.ContentEncoding = ContentEncoding;
     }
     if (Data != null)
     {
         JavaScriptSerializer serializer = new JavaScriptSerializer();
         string jsonstring = serializer.Serialize(Data);
         string p = @"\\/Date\(\d+\)\\/";
         MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
         Regex reg = new Regex(p);
         jsonstring = reg.Replace(jsonstring, matchEvaluator);
         response.Write(jsonstring);
     }
 }
开发者ID:494324190,项目名称:Blog,代码行数:35,代码来源:ToJsonResult.cs


示例2: Minify

        public static string Minify(System.Web.Mvc.UrlHelper urlHelper, string cssPath, string requestPath, string cssContent)
        {
            // this construct is to enable us to refer to the relativePath above ...
            MatchEvaluator urlDelegate = new MatchEvaluator(delegate(Match m)
            {
                // Change relative (to the original CSS) URL references to make them relative to the requested URL (controller / action)
                string url = m.Value;

                Uri uri = new Uri(url, UriKind.RelativeOrAbsolute);

                if (uri.IsAbsoluteUri || VirtualPathUtility.IsAbsolute(url))
                {
                    // if the URL is absolute ("http://server/path/file.ext") or app absolute ("/path/file.ext") then leave it as it is
                }
                else
                {
                    // get app relative url
                    url = VirtualPathUtility.Combine(cssPath, url);
                    url = VirtualPathUtility.MakeRelative(requestPath, url);

                    url = urlHelper.Content(url);
                }

                return url;
            });
            return Minify(urlHelper, urlDelegate, cssContent, 0);
        }
开发者ID:kooboo-jifeng,项目名称:CMS,代码行数:27,代码来源:CssMinify.cs


示例3: ExecuteResult

        /// <summary>
        /// 重写执行视图
        /// </summary>
        /// <param name="context">上下文</param>
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            HttpResponseBase response = context.HttpContext.Response;

            if (string.IsNullOrEmpty(this.ContentType))
            {
                response.ContentType = this.ContentType;
            }
            else
            {
                response.ContentType = "application/json";
            }

            if (this.ContentEncoding != null)
            {
                response.ContentEncoding = this.ContentEncoding;
            }

            if (this.Data != null)
            {
                JavaScriptSerializer jss = new JavaScriptSerializer();
                string jsonString = jss.Serialize(Data);
                string p = @"\\/Date\((\d+)\)\\/";
                MatchEvaluator matchEvaluator = new MatchEvaluator(this.ConvertJsonDateToDateString);
                Regex reg = new Regex(p);
                jsonString = reg.Replace(jsonString, matchEvaluator);

                response.Write(jsonString);
            }
        }
开发者ID:jinhonglin,项目名称:DotNetStudio,代码行数:39,代码来源:CustomJsonResult.cs


示例4: DecodeNoTextileZones

 public static string DecodeNoTextileZones(string tmp, string patternPrefix, string patternSuffix, string[] exceptions)
 {
     m_decodeExceptions = exceptions;
     MatchEvaluator me = new MatchEvaluator(DecodeNoTextileZonesMatchEvaluator);
     tmp = Regex.Replace(tmp, string.Format("({0}(?<notex>.+?){1})*", patternPrefix, patternSuffix), me);
     return tmp;
 }
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:7,代码来源:NoTextileEncoder.cs


示例5: ShowEscapeChars

		/// <summary>
		/// Replaces the characters null, alert, backspace, form feed,
		/// newline, carriage return, horizontal tab and vertical tab
		/// with their escaped version. This allows you to show
		/// the escape characters.
		/// </summary>
		/// <param name="str"></param>
		/// <returns></returns>
		public static string ShowEscapeChars(string str)
		{
			Regex regex = new Regex("\0|\a|\b|\f|\n|\r|\t|\v");
			MatchEvaluator evaluator = 
				new MatchEvaluator((new StringUtil()).MatchEvent);
			return regex.Replace(str,evaluator);
		}
开发者ID:CSRedRat,项目名称:pascalabcnet,代码行数:15,代码来源:StringUtil.cs


示例6: ChangeAgentDB

 private static void ChangeAgentDB()
 {
     if (File.Exists(".agent.db"))
     {
         var text = File.ReadAllText(".agent.db");
         var evaluator1 = new MatchEvaluator(replaceAgent1);
         text = Regex.Replace(
             text,
             "(\"s2_)([A-Za-z]{4})(\")",
             evaluator1
             );
         text = Regex.Replace(
             text,
             "(http://)([A-Za-z]{4})(.patch.battle.net:1119/patch)",
             evaluator1
             );
         text = Regex.Replace(
             text,
             "(\"installed_locales\" : " + @"\[\s+" + "\")([A-Za-z]{4})(\")",
             evaluator1
             );
         text = Regex.Replace(
             text,
             "(\"display_locales\" : " + @"\[\s+" + "\")([A-Za-z]{4})(\")",
             evaluator1
             );
         File.Delete(".agent.db");
         File.WriteAllText(".agent.db", text);
     }
 }
开发者ID:lhr0909,项目名称:SC2Patch150Relocalizer,代码行数:30,代码来源:LocaleChanger.cs


示例7: Build

	internal string Build (SubtitleCollection collection, SubtitleProperties subtitleProperties, FileProperties fileProperties) {
		this.subtitleProperties = subtitleProperties;
		StringBuilder output = new StringBuilder();
		if (format.HasHeaders)
			output.Append(format.HeadersToString(subtitleProperties, fileProperties));

		if (format.HasBodyBegin)
			output.Append(format.BodyBeginOut);

		string subtitleExpression = GetSubtitleExpression(format, subtitleProperties, fileProperties);
		Regex fieldExpression = new Regex(@"<<(?<Field>\w+)(,(?<Width>\d+))?>>");
		MatchEvaluator matchEvaluator = new MatchEvaluator(this.FieldEvaluator);

		foreach (Subtitle currentSubtitle in collection) {
			subtitle = currentSubtitle;
			string outputSubtitle = fieldExpression.Replace(subtitleExpression, matchEvaluator);
			output.Append(outputSubtitle);
			output.Append("\n");
			subtitleNumber++;
			previousSubtitle = subtitle;
		}

		if (format.HasBodyEnd)
			output.Append(format.BodyEndOut);

		subtitle = null;
		previousSubtitle = null;
		subtitleNumber = 1;

		ConvertNewlines(output, fileProperties);
		return output.ToString();
	}
开发者ID:GNOME,项目名称:gnome-subtitles,代码行数:32,代码来源:SubtitleOutput.cs


示例8: ExpandUrls

        /// <summary>
        /// Expands links into HTML hyperlinks inside of text or HTML.
        /// </summary>
        /// <param name="text">The text to expand</param>    
        /// <returns></returns>
        public string ExpandUrls(string text)
        {
            MatchEvaluator matchEval = null;
            string pattern = null;
            string updated = null;

            // *** Expand embedded hyperlinks
            RegexOptions options =
                                                                  RegexOptions.Multiline |
                                                                  RegexOptions.IgnoreCase;

            if (ParseFormattedLinks)
            {
                pattern = @"\[(.*?)\|(.*?)]";

                matchEval = new MatchEvaluator(ExpandFormattedLinks);
                updated = Regex.Replace(text, pattern, matchEval, options);
            }
            else
                updated = text;

            pattern = @"([""'=]|&quot;)?(http://|ftp://|https://|www\.|ftp\.[\w]+)([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])";

            matchEval = new MatchEvaluator(ExpandUrlsRegExEvaluator);
            updated = Regex.Replace(updated, pattern, matchEval, options);

            return updated;
        }
开发者ID:eugenioalonso,项目名称:wwDotnetBridge,代码行数:33,代码来源:StringUtils.cs


示例9: MinifyJavascript

		public string MinifyJavascript(string text)
		{
			// remove /* ... */ comments
			text = Regex.Replace(text, @"(?<!/)/\*((?!\*/).)*\*/", string.Empty, RegexOptions.Singleline);

			// remove // comments - remove all text beginning with // unless it is a hyperlink
			text = Regex.Replace(text, @"(?<!https?:)//[^\n\r]*[\n\r]", string.Empty, RegexOptions.IgnoreCase);

			//remove all line breaks and tabs
			text = Regex.Replace(text, @"[\f\n\r\t\v]", string.Empty, RegexOptions.Singleline);

			//remove all extraneous spaces
			text = Regex.Replace(text, @" {2,}", string.Empty);

			// temporarily replace spaces with a character sequence in the following: string phrases ("" or ''), regular expressions (//)
			var evaluator = new MatchEvaluator(ReplaceSpaces);
			text = Regex.Replace(text, @"'[^']*'|""[^""]*""", evaluator);

			// remove any spaces around code characters - excluded: / (because it is used for regular expressions)
			var codeCharacters = "[+*=(){}<>!|,;:?&-]+";
			text = Regex.Replace(text, @"(?<!/) *(" + codeCharacters + ") *", "$1");

			// restore spaces
			text = text.Replace("~¬@~", " ");

			return text;
		}
开发者ID:porl88,项目名称:Website-MVC,代码行数:27,代码来源:MinificationService.cs


示例10: Fix

 public static string Fix(object data, MatchEvaluator replacer = null)
 {
     if (data == null) return null;
     string fixed_data;
     if (replacer != null) fixed_data = ControlChars.Value.Replace(data.ToString(), replacer);
     else fixed_data = ControlChars.Value.Replace(data.ToString(), FixData_Replace);
     return fixed_data;
 }
开发者ID:BillerFaktura,项目名称:Biller.Core,代码行数:8,代码来源:XML.cs


示例11: ChangeContent

 // Replace some swf to mp4.
 public static void ChangeContent(ref string content, string pattern, MatchEvaluator evaluator)
 {
     Regex grx = new Regex(pattern, RegexOptions.IgnoreCase);
     if (grx.IsMatch(content))
     {
         content = grx.Replace(content, evaluator);
     }
 }
开发者ID:englishtown,项目名称:OfflinePackageBuilder,代码行数:9,代码来源:ContentHelper.cs


示例12: ComplexReplace

        /// <summary>
        /// 
        /// </summary>
        /// <param name="matchPattern"></param>
        /// <param name="source"></param>
        public static void ComplexReplace(string matchPattern, string source)
        {
            MatchEvaluator replaceCallback = new MatchEvaluator(MatchHandler);
            Regex RE = new Regex(matchPattern, RegexOptions.Multiline);
            string newString = RE.Replace(source, replaceCallback);

            Console.WriteLine("Replaced String = " + newString);
        }
开发者ID:peeboo,项目名称:open-media-library,代码行数:13,代码来源:RegexUtils.cs


示例13: ConvertVariableLikeTOCInlines

        public static string ConvertVariableLikeTOCInlines(string text, PreprocessedTextLocationMap map)
        {
            var evaluator = new MatchEvaluator(match => "[" + match.Groups["content"].Value + "]");

            return map == null
                       ? TOCPatternVariableLike.Replace(text, evaluator)
                       : Preprocessor.Replace(TOCPatternVariableLike, text, evaluator, map);
        }
开发者ID:Art1stical,项目名称:AHRUnrealEngine,代码行数:8,代码来源:EMTOCInline.cs


示例14: Replace

        /// <summary>
        /// 替换标签
        /// </summary>
        /// <param name="html"></param>
        /// <param name="eval"></param>
        /// <returns></returns>
        public static string Replace(string html, MatchEvaluator eval)
        {
            //如果包含部分视图,则替换成部分视图的内容
            //ReplacePartial(html);

            //替换匹配
            return tagRegex.Replace(html, eval);
        }
开发者ID:ReinhardHsu,项目名称:devfw,代码行数:14,代码来源:TemplateRegexUtility.cs


示例15: ExpandUrls

 public static string ExpandUrls(string inputText)
 {
     string pattern = @"[""'=]?(http://|ftp://|https://|www\.|ftp\.[\w]+)([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])";
     System.Text.RegularExpressions.RegexOptions options = RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline | RegexOptions.IgnoreCase;
     System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(pattern, options);
     MatchEvaluator MatchEval = new MatchEvaluator(ExpandUrlsRegExEvaluator);
     return Regex.Replace(inputText, pattern, MatchEval);
 }
开发者ID:joinpramod,项目名称:MyBlogWebsiteMVC2015,代码行数:8,代码来源:Utilities.cs


示例16: CreateClassName

		public String CreateClassName(String tableName)
		{
			MatchEvaluator UpCaser = new MatchEvaluator(UpCaserDef);

			tableName = Regex.Replace(tableName, "(tb_|_)", "");
			tableName = Regex.Replace(tableName, "^[a-z]", UpCaser);

			return Singularize(tableName);
		}
开发者ID:atczyc,项目名称:castle,代码行数:9,代码来源:NamingService.cs


示例17: ReplaceNestedSequence

 protected override string ReplaceNestedSequence(string templateText, string regExPattern,
     MatchEvaluator evaluator)
 {
     var result = templateText;
     Regex regEx = new Regex(regExPattern);
     while (regEx.IsMatch(result))
         result = regEx.Replace(result, evaluator);
     return result;
 }
开发者ID:oleguchok,项目名称:Template-Performer-Client-Server,代码行数:9,代码来源:CSharpTemplateParser.cs


示例18: TagBasedConvertRegex

        static string TagBasedConvertRegex(string input)
        {
            Regex r = new Regex("(<upcase>)(.+?)(</upcase>)");

            MatchEvaluator eval = new MatchEvaluator(Replace);

            string result = r.Replace(input, eval);
            return result;
        }
开发者ID:mitev-web,项目名称:csharp-fundamentals,代码行数:9,代码来源:Program.cs


示例19: CreateRelationName

		public String CreateRelationName(String tableName)
		{
			MatchEvaluator UpCaser = new MatchEvaluator(UpCaserDef);

			tableName = Regex.Replace(tableName, "(tb_|_)", "");
			tableName = Regex.Replace(tableName, "^[a-z]", UpCaser);

			return Pluralize(tableName);
		}
开发者ID:atczyc,项目名称:castle,代码行数:9,代码来源:NamingService.cs


示例20: HtmlFormatRaw

        /// <summary>
        /// A raw Html version of string.Format. This returns Html as text and
        /// not an HtmlString for easier manipulation.
        /// </summary>
        /// <param name="format">The format for the string this includes html</param>
        /// <param name="args"></param>
        /// <exception cref="FormatException">Thrown when the indexes in the format
        /// string are larger than the number of arguments passed.</exception>
        /// <returns></returns>
        public static string HtmlFormatRaw(this string format, params object[] args)
        {
            const string FormatSyntax = @"{(?<index>\d+)(?<rest>(?:,\-?\d+)?(?:\:\w+)?)}";

            var func = new Func<object[], Match, string>(HtmlFormatter);
            var eval = new MatchEvaluator(func.Curry(args));

            return Regex.Replace(format, FormatSyntax, eval);
        }
开发者ID:jeremiahredekop,项目名称:Nvelope,代码行数:18,代码来源:HtmlExtensions.cs



注:本文中的MatchEvaluator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MatchState类代码示例发布时间:2022-05-24
下一篇:
C# Match类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap