static bool Regex_Replace__String__String__MatchEvaluator__RegexOptions(JSVCall vc, int argc) { int len = argc; if (len == 4) { System.String arg0 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg); System.String arg1 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg); System.Text.RegularExpressions.MatchEvaluator arg2 = JSDataExchangeMgr.GetJSArg <System.Text.RegularExpressions.MatchEvaluator>(() => { if (JSApi.isFunctionS((int)JSApi.GetType.Arg)) { return(Regex_Replace_GetDelegate_member31_arg2(JSApi.getFunctionS((int)JSApi.GetType.Arg))); } else { return((System.Text.RegularExpressions.MatchEvaluator)JSMgr.datax.getObject((int)JSApi.GetType.Arg)); } }); System.Text.RegularExpressions.RegexOptions arg3 = (System.Text.RegularExpressions.RegexOptions)JSApi.getEnum((int)JSApi.GetType.Arg); JSApi.setStringS((int)JSApi.SetType.Rval, System.Text.RegularExpressions.Regex.Replace(arg0, arg1, arg2, arg3)); } return(true); }
private string GetRegexPattern(string abbr) { string numbers = "[0-9]+"; var regex = new System.Text.RegularExpressions.Regex(numbers); var matches = regex.Matches(abbr); var evaluator = new System.Text.RegularExpressions.MatchEvaluator(EntryNumber); return("^" + regex.Replace(abbr, evaluator) + "$"); }
public string CreateAndLoadClass() { serial++; string path = string.Format("{0}match{1}.cs", Path.GetTempPath(), serial); StreamWriter writer = File.CreateText(path); string text2 = string.Format("MatchEvaluator{0}", serial); writer.WriteLine("using System;"); writer.WriteLine("using System.Text.RegularExpressions;"); writer.WriteLine("class {0} {{", text2); writer.WriteLine(this.matchEvaluatorString); writer.WriteLine("}"); writer.Close(); Version version = Environment.Version; string text3 = string.Format(@"c:\windows\microsoft.net\framework\v{0}.{1}.{2}", version.Major, version.Minor, version.Build); string text4 = Path.GetTempPath() + "BuildMatch.bat"; writer = File.CreateText(text4); writer.WriteLine("set path=%path%;{0}", text3); writer.WriteLine("csc /nologo /t:library {0}", path); writer.Close(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = text4; info.WorkingDirectory = Path.GetTempPath(); info.CreateNoWindow = true; info.RedirectStandardOutput = true; info.UseShellExecute = false; Process process = new Process(); process.StartInfo = info; process.Start(); process.WaitForExit(); if (process.ExitCode != 0) { string[] textArray = process.StandardOutput.ReadToEnd().Split(new char[] { '\n' }); string text5 = ""; for (int i = 4; i < textArray.Length; i++) { text5 = text5 + textArray[i]; } return(text5); } try { MethodInfo method = Assembly.LoadFrom(path.Replace(".cs", ".dll")).GetType(text2).GetMethod("Evaluator"); this.matchEvaluator = (System.Text.RegularExpressions.MatchEvaluator)Delegate.CreateDelegate(typeof(System.Text.RegularExpressions.MatchEvaluator), method); } catch (Exception exception) { return(exception.ToString()); } return(null); }
static bool Regex_Replace__String__MatchEvaluator__Int32(JSVCall vc, int argc) { int len = argc; if (len == 3) { System.String arg0 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg); System.Text.RegularExpressions.MatchEvaluator arg1 = JSDataExchangeMgr.GetJSArg <System.Text.RegularExpressions.MatchEvaluator>(() => { if (JSApi.isFunctionS((int)JSApi.GetType.Arg)) { return(Regex_Replace_GetDelegate_member14_arg1(JSApi.getFunctionS((int)JSApi.GetType.Arg))); } else { return((System.Text.RegularExpressions.MatchEvaluator)JSMgr.datax.getObject((int)JSApi.GetType.Arg)); } }); System.Int32 arg2 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg); JSApi.setStringS((int)JSApi.SetType.Rval, ((System.Text.RegularExpressions.Regex)vc.csObj).Replace(arg0, arg1, arg2)); } return(true); }
public string CreateAndLoadClass() { serial++; string path = string.Format("{0}match{1}.cs", Path.GetTempPath(), serial); StreamWriter writer = File.CreateText(path); string text2 = string.Format("MatchEvaluator{0}", serial); writer.WriteLine("using System;"); writer.WriteLine("using System.Text.RegularExpressions;"); writer.WriteLine("class {0} {{", text2); writer.WriteLine(this.matchEvaluatorString); writer.WriteLine("}"); writer.Close(); Version version = Environment.Version; string text3 = string.Format(@"c:\windows\microsoft.net\framework\v{0}.{1}.{2}", version.Major, version.Minor, version.Build); string text4 = Path.GetTempPath() + "BuildMatch.bat"; writer = File.CreateText(text4); writer.WriteLine("set path=%path%;{0}", text3); writer.WriteLine("csc /nologo /t:library {0}", path); writer.Close(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = text4; info.WorkingDirectory = Path.GetTempPath(); info.CreateNoWindow = true; info.RedirectStandardOutput = true; info.UseShellExecute = false; Process process = new Process(); process.StartInfo = info; process.Start(); process.WaitForExit(); if (process.ExitCode != 0) { string[] textArray = process.StandardOutput.ReadToEnd().Split(new char[] { '\n' }); string text5 = ""; for (int i = 4; i < textArray.Length; i++) { text5 = text5 + textArray[i]; } return text5; } try { MethodInfo method = Assembly.LoadFrom(path.Replace(".cs", ".dll")).GetType(text2).GetMethod("Evaluator"); this.matchEvaluator = (System.Text.RegularExpressions.MatchEvaluator) Delegate.CreateDelegate(typeof(System.Text.RegularExpressions.MatchEvaluator), method); } catch (Exception exception) { return exception.ToString(); } return null; }
/// <summary>Load language files and preprocess them. Loads xsl file.</summary> /// <remarks>Call this method to reload the language files.</remarks> public bool Init() { // Replace function delegate ReplaceByCodeDelegate = new System.Text.RegularExpressions.MatchEvaluator( ReplaceByCode ); // hashtable for regular expressions RxDic = new Collections.RegexDictionary(); // prepare tags EndOfLine="\n"; OpeningTag = "<"; ClosingTag = ">"; Tag = "pre"; LangTag = "lang"; InBox=true; Timer = new AvgTimer(); try { // load and preprocess language data LanguageSyntax=new XmlDocument(); BuildSyntax( ); // load xsl.. LanguageStyle=new XslTransform(); LanguageStyle.Load( LanguageStyleFileName ); return true; } catch(Exception e) { Log.Fatal(e); throw e; } }