protected override Core.Tokenization.Token CreateToken(string s, System.Text.RegularExpressions.GroupCollection groups) { string cur = groups["cur"].Value; string num = groups["num"].Value; string sep = groups["sep"].Value; string decimalPart = groups["sdec"].Value; if (String.IsNullOrEmpty(decimalPart)) { decimalPart = groups["gdec"].Value; } char separator = (sep.Length > 0) ? sep[0] : '\0'; Core.Tokenization.MeasureToken value = new Core.Tokenization.MeasureToken(s, groups["sign"].Value, decimalPart, groups["frac"].Value, Core.Tokenization.Unit.Currency, cur, separator, _Culture.NumberFormat); value.Unit = Core.Tokenization.Unit.Currency; return(value); }
/// <summary> /// 正则查找 /// </summary> /// <param name="reString">正文</param> /// <param name="regexCode">正则表达式</param> /// <returns>返回结果(单条数据)</returns> public static string GetRegexStr(string reString, string regexCode) { try { System.Text.RegularExpressions.Regex reg; //正则表达式变量 reg = new System.Text.RegularExpressions.Regex(regexCode); //初始化正则对象 System.Text.RegularExpressions.MatchCollection mc = reg.Matches(reString); //匹配; string temp = string.Empty; //声明一个临时变量 for (int ic = 0; ic < mc.Count; ic++) { System.Text.RegularExpressions.GroupCollection gc = mc[ic].Groups;//获取所有分组 System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection(); for (int i = 0; i < gc.Count; i++) { temp = gc[i].Value; //得到组对应数据 } } return(temp); } catch { TextAdditional("正则查找失败"); return(string.Empty); } }
protected override Visibility _Decode(System.Text.RegularExpressions.GroupCollection grp) { Visibility ret = null; if (grp[0].Success) { ret = new Visibility(); if (grp[2].Success) { ret.SetCAVOK(); } else if (grp[3].Success) { ret.SetMeters(grp[3].GetIntValue()); } else { ret.SetMiles( new Racional( grp[7].Success ? grp[7].GetIntValue() : 0, grp[8].GetIntValue(), (grp[9].Success) ? grp[10].GetIntValue() : 1), grp[6].Success); } } return(ret); }
protected override DayHourDayHour _Decode(System.Text.RegularExpressions.GroupCollection groups) { DayHourDayHour ret = null; ret = DecodeRegularTaf(groups); return(ret); }
protected override Common.eSeaState?_Decode(System.Text.RegularExpressions.GroupCollection groups) { int pom = groups[1].GetIntValue(); Common.eSeaState ret = (Common.eSeaState)pom; return(ret); }
protected override WindShear _Decode(System.Text.RegularExpressions.GroupCollection groups) { WindShear ret = new WindShear(); ret.Runway = groups[1].Value; return(ret); }
protected override WindVariable _Decode(System.Text.RegularExpressions.GroupCollection groups) { WindVariable ret = new WindVariable(); ret.FromDirection = groups[2].GetIntValue(); ret.ToDirection = groups[3].GetIntValue(); return(ret); }
protected override DayHourMinute _Decode(System.Text.RegularExpressions.GroupCollection groups) { DayHourMinute ret = new DayHourMinute(); ret.Day = groups[1].GetIntValue(); ret.Hour = groups[2].GetIntValue(); ret.Minute = groups[3].GetIntValue(); return(ret); }
protected override bool _Decode(System.Text.RegularExpressions.GroupCollection groups) { if (groups[0].Success) { return(true); } else { return(false); } }
protected override int _Decode(System.Text.RegularExpressions.GroupCollection groups) { int ret = groups[2].GetIntValue(); if (groups[1].Success) { ret = -ret; } return(ret); }
protected override VisibilityForMetar _Decode(System.Text.RegularExpressions.GroupCollection groups) { VisibilityForMetar ret = new VisibilityForMetar(); if (groups[2].Success) { ret.SetCAVOK(); } else if (groups[3].Success) { ret.SetSKC(); } else if (groups[4].Success) { int distance = groups[5].GetIntValue(); Common.eDirection?dir = null; int?otherDist = null; Common.eDirection?otherDir = null; if (groups[6].Success) { dir = (Common.eDirection)Enum.Parse( typeof(Common.eDirection), groups[6].Value, false); } if (groups[7].Success) { otherDist = groups[8].GetIntValue(); otherDir = (Common.eDirection)Enum.Parse( typeof(Common.eDirection), groups[9].Value, false); } ret.SetMeters(distance, dir, otherDist, otherDir); } else { Racional r = new Racional( (groups[13].Success) ? groups[13].GetIntValue() : 0, groups[14].GetIntValue(), (groups[16].Success) ? groups[16].GetIntValue() : 1 ); bool isMinimal = groups[12].Success; ret.SetMiles(r, isMinimal); } return(ret); }
protected override PressureInfo _Decode(System.Text.RegularExpressions.GroupCollection groups) { PressureInfo ret = new PressureInfo(); if (groups[2].Value == "Q") { ret.Set(groups[3].GetIntValue(), PressureInfo.eUnit.hPa); } else { ret.Set(groups[3].GetIntValue() / 100.0, PressureInfo.eUnit.mmHq); } return(ret); }
protected virtual Core.Tokenization.Token CreateToken(string s, System.Text.RegularExpressions.GroupCollection groups) { Token t = null; if (_Type == TokenType.OtherTextPlaceable) { t = new GenericPlaceableToken(s, TokenClassName, _AutoSubstitutable); } else { t = new SimpleToken(s, _Type); } return(t); }
protected override Core.Tokenization.Token CreateToken(string s, System.Text.RegularExpressions.GroupCollection groups) { string decimalPart = groups["sdec"].Value; if (String.IsNullOrEmpty(decimalPart)) { decimalPart = groups["gdec"].Value; } NumberToken value = new NumberToken(s, groups["sign"].Value, decimalPart, groups["frac"].Value, _NumberFormat); return(value); }
private DayHourDayHour DecodeRegularTaf(System.Text.RegularExpressions.GroupCollection groups) { DayHourDayHour ret = new DayHourDayHour(); int fd = groups[2].GetIntValue(); int fh = groups[3].GetIntValue(); int td = groups[4].GetIntValue(); int th = groups[5].GetIntValue(); ret.From = new DayHour(fd, fh); ret.To = new DayHour(td, th); return(ret); }
static StackObject *get_IsReadOnly_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Text.RegularExpressions.GroupCollection instance_of_this_method = (System.Text.RegularExpressions.GroupCollection) typeof(System.Text.RegularExpressions.GroupCollection).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.IsReadOnly; __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
protected override Metar.eType _Decode(System.Text.RegularExpressions.GroupCollection groups) { Metar.eType ret; if (groups[1].Success) { ret = Metar.eType.METAR; } else if (groups[2].Success) { ret = Metar.eType.SPECI; } else { throw new NotSupportedException(); } return(ret); }
internal PageRequest(ThreadEntity entity) { _innerRequest = entity.WebContext.Request; _values = new System.Collections.Specialized.NameValueCollection(); _groupNvc = new System.Collections.Specialized.NameValueCollection(); System.Text.RegularExpressions.GroupCollection _groupMatched = entity.URLItem.Regex.Match(entity.URL.Path).Groups; for (int i = 0; i < entity.URLItem.URLGroupsName.Length; i++) { string _key = entity.URLItem.URLGroupsName[i]; _groupNvc.Add(_key, _groupMatched[_key].Value); } _values.Add(_innerRequest.QueryString); _values.Add(_innerRequest.Form); _values.Add(_groupNvc); }
static StackObject *get_Item_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Int32 @groupnum = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Text.RegularExpressions.GroupCollection instance_of_this_method = (System.Text.RegularExpressions.GroupCollection) typeof(System.Text.RegularExpressions.GroupCollection).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method[groupnum]; return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
protected override TemperatureExtremeTX _Decode(System.Text.RegularExpressions.GroupCollection groups) { TemperatureExtremeTX ret = new TemperatureExtremeTX(); bool negate = groups[1].Success; ret.Temperature = groups[2].GetIntValue(); if (negate) { ret.Temperature = -ret.Temperature; } ret.Time = new DayHour(); ret.Time.Day = groups[3].GetIntValue(); ret.Time.Hour = groups[4].GetIntValue(); return(ret); }
protected override RunwayCondition _Decode(System.Text.RegularExpressions.GroupCollection groups) { RunwayCondition ret = new RunwayCondition(); ret.Runway = groups[1].Value; if (groups[8].Success) { ret.IsCleared = true; } else { ret.Deposit = (groups[4].Value == "/" ? null : (RunwayCondition.eDeposit?)groups[4].GetIntValue()); ret.Contamination = (groups[5].Value == "/" ? null : (RunwayCondition.eContamination?)groups[5].GetIntValue()); ret.Depth = (groups[6].Value == "//" ? null : (RunwayCondition.eDepth?)groups[6].GetIntValue()); ret.Friction = (groups[7].Value == "//" ? null : (RunwayCondition.eFriction?)groups[7].GetIntValue()); } return(ret); }
static StackObject *get_SyncRoot_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Text.RegularExpressions.GroupCollection instance_of_this_method = (System.Text.RegularExpressions.GroupCollection) typeof(System.Text.RegularExpressions.GroupCollection).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.SyncRoot; object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true)); }
static StackObject *CopyTo_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Int32 @arrayIndex = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Array @array = (System.Array) typeof(System.Array).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.Text.RegularExpressions.GroupCollection instance_of_this_method = (System.Text.RegularExpressions.GroupCollection) typeof(System.Text.RegularExpressions.GroupCollection).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.CopyTo(@array, @arrayIndex); return(__ret); }
protected override RunwayVisibility _Decode(System.Text.RegularExpressions.GroupCollection groups) { RunwayVisibility ret = new RunwayVisibility(); ret.Runway = groups[3].Value; if (groups[5].Success) { ret.DeviceMeasurementRestriction = (RunwayVisibility.eDeviceMeasurementRestriction)Enum.Parse( typeof(RunwayVisibility.eDeviceMeasurementRestriction), groups[5].Value, false); } else { ret.DeviceMeasurementRestriction = null; } ret.Distance = groups[6].GetIntValue(); if (groups[7].Success) { ret.VariableDistance = groups[8].GetIntValue(); } if (groups[9].Success) { if (groups[9].Value == "FT") { ret.Unit = Common.eDistanceUnit.ft; ret.Tendency = null; } else { ret.Unit = Common.eDistanceUnit.m; ret.Tendency = (RunwayVisibility.eTendency) Enum.Parse(typeof(RunwayVisibility.eTendency), groups[9].Value, false); } } return(ret); }
public string format(System.Text.RegularExpressions.GroupCollection r) { //r[m.grp].Value.Trim(' ', '\t', '\r', '\n'); if (r.Count <= max) { return(null); } StringBuilder ret = new StringBuilder(); foreach (YieldMember ym in mset) { if (ym.bref < 0) { ret.Append(ym.text); } else { ret.Append(r[ym.bref].Value.Trim(' ', '\t', '\r', '\n')); } } return(ret.ToString()); }
protected static void GetMatchGroups(string pattern, string text, out System.Text.RegularExpressions.GroupCollection groups, out int matchesCount) { System.Text.RegularExpressions.Regex regex; groups = null; matchesCount = 0; text = text.ToUpper(); regex = new System.Text.RegularExpressions.Regex(pattern); System.Text.RegularExpressions.MatchCollection matches = regex.Matches(text); do { matchesCount = matches.Count; if (matchesCount < 1) { break; } // get groups System.Text.RegularExpressions.Match match = matches[0]; groups = match.Groups; }while (false); }
/// <summary> /// Xml转化为类 /// </summary> public static T XmlToObject <T>(this string XmlString, string Pattern = null, System.Reflection.BindingFlags bindingAttr = System.Reflection.BindingFlags.Public) { T TObj = System.Activator.CreateInstance <T>(); System.Reflection.PropertyInfo[] Properties = typeof(T).GetProperties(bindingAttr); if (Properties.Length > 0) { foreach (System.Reflection.PropertyInfo item in Properties) { if (item.CanWrite) { System.Text.RegularExpressions.GroupCollection Groups = System.Text.RegularExpressions.Regex.Match(XmlString, "<" + item.Name + ">(.*)</" + item.Name + ">").Groups; if (Groups.Count > 1) { if (Pattern != null) { string GroupsValue = Groups[1].Value; Groups = System.Text.RegularExpressions.Regex.Match(GroupsValue, Pattern.Replace("[", @"\[").Replace("]", @"\]").Replace("(", @"\(").Replace(")", @"\)").Replace("{1}", "(.*)")).Groups; if (Groups.Count > 1) { item.SetValue(TObj, Convert.ChangeType(Groups[1].Value, item.PropertyType), null); } else { item.SetValue(TObj, Convert.ChangeType(GroupsValue, item.PropertyType), null); } } else { item.SetValue(TObj, Convert.ChangeType(Groups[1].Value, item.PropertyType), null); } } } } } return(TObj); }
protected override bool _Decode(System.Text.RegularExpressions.GroupCollection groups) { return(true); }
public static IEnumerable <System.Text.RegularExpressions.Group> AsEnumerable(this System.Text.RegularExpressions.GroupCollection gc) { foreach (System.Text.RegularExpressions.Group g in gc) { yield return(g); } }
/// <summary> /// Figire out type of the request - file or some service (CGI). Deliver the data to the HTTP client /// </summary> protected void ProcessRequest(string rootPath, System.Net.Sockets.NetworkStream networkStream, string clientRequest, ref bool stream) { System.Text.RegularExpressions.MatchCollection matches = regexPatternGet.Matches(clientRequest); int matchesCount = matches.Count; string filenameFull; bool useCache = true; if (matchesCount == 1) { // get groups System.Text.RegularExpressions.Match match = matches[0]; System.Text.RegularExpressions.GroupCollection groups = match.Groups; string filename = groups[1].Captures[0].ToString(); // group[0] is reserved for the whole match filenameFull = filename; // server does not care about subdirectories. Send only files in the root directory filename = System.IO.Path.GetFileName(filename); // no file means index.html file if (filename.Length == 0) { filenameFull = "index_local.html"; useCache = false; // else System.Console.WriteLine(filename); } // i have to figure out if this is a file or CGI script (management request) // management requests contain '?' (this is likely) int indexQuestionMark = filename.IndexOf('?'); if (indexQuestionMark > 0) { Http.statistics.httpRequests++; string name = filename.Substring(0, indexQuestionMark); // look in the list of all CGI scripts and if found - call the delegate method HttpRequestHandler handler = Http.FindRequestHandler(name); // System.Console.WriteLine(name); if (handler != default(HttpRequestHandler)) { handler(clientRequest, networkStream, out stream); } else { Http.statistics.errorHttpRequestNotFound++; System.Console.WriteLine("Unknown request:" + name); Http.SendErrorFileNotExist(networkStream, name); } } else // this is less likely - get actual file { Http.statistics.files++; // add root filename = rootPath + filenameFull; // send the file Http.SendFile(networkStream, filename, useCache); } } }