예제 #1
0
        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);
        }
예제 #2
0
        /// <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);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        protected override DayHourDayHour _Decode(System.Text.RegularExpressions.GroupCollection groups)
        {
            DayHourDayHour ret = null;

            ret = DecodeRegularTaf(groups);

            return(ret);
        }
예제 #5
0
        protected override Common.eSeaState?_Decode(System.Text.RegularExpressions.GroupCollection groups)
        {
            int pom = groups[1].GetIntValue();

            Common.eSeaState ret = (Common.eSeaState)pom;

            return(ret);
        }
예제 #6
0
        protected override WindShear _Decode(System.Text.RegularExpressions.GroupCollection groups)
        {
            WindShear ret = new WindShear();

            ret.Runway = groups[1].Value;

            return(ret);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
 protected override bool _Decode(System.Text.RegularExpressions.GroupCollection groups)
 {
     if (groups[0].Success)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #10
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
 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);
 }
예제 #18
0
        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);
        }
예제 #19
0
        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));
        }
예제 #20
0
        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);
        }
예제 #21
0
        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);
        }
예제 #22
0
        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));
        }
예제 #23
0
        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);
        }
예제 #24
0
        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);
        }
예제 #25
0
                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());
                }
예제 #26
0
        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);
        }
예제 #27
0
        /// <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);
        }
예제 #28
0
 protected override bool _Decode(System.Text.RegularExpressions.GroupCollection groups)
 {
     return(true);
 }
예제 #29
0
 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);
     }
 }
예제 #30
0
            /// <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);
                    }
                }
            }