Ejemplo n.º 1
0
        public static GWEventType[] Parse(string strValue)
        {
            if (strValue == null)
            {
                return(null);
            }
            List <GWEventType> list = new List <GWEventType>();

            string[] olist = strValue.Split(_objectSeperator);
            foreach (string o in olist)
            {
                string ostr = o.TrimStart().TrimEnd(_objectSeperator);
                if (ostr.Length < 1)
                {
                    continue;
                }

                // parse event type
                GWEventType eventType = new GWEventType();
                string[]    vlist     = ostr.Split(_valueSeperator);
                if (vlist.Length > 0)
                {
                    eventType.Description = vlist[0];
                }
                if (vlist.Length > 1)
                {
                    eventType.Code = vlist[1];
                }
                if (vlist.Length > 2)
                {
                    try
                    {
                        eventType.Enable = bool.Parse(vlist[2].Trim());
                    }
                    catch
                    {
                        eventType.Enable = false;
                    }
                }

                // check event type
                if (eventType.Code.Trim().Length < 1)
                {
                    continue;
                }
                foreach (GWEventType t in EventTypes)
                {
                    if (t.Code == eventType.Code)
                    {
                        eventType.Description = t.Description;
                        break;
                    }
                }

                list.Add(eventType);
            }
            return(list.ToArray());
        }
Ejemplo n.º 2
0
        public GWEventType Clone()
        {
            GWEventType t = new GWEventType();

            t.Description = Description;
            t.Enable      = Enable;
            t.Code        = Code;
            return(t);
        }
Ejemplo n.º 3
0
        private static GWEventType[] GetEventTypes()
        {
            Type t = Empty.GetType();
            List <GWEventType> fieldList = new List <GWEventType>();

            FieldInfo[] flist = t.GetFields(BindingFlags.Static | BindingFlags.Public);
            foreach (FieldInfo f in flist)
            {
                object o = t.InvokeMember(f.Name,
                                          BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField,
                                          null, Empty, new object[] { });

                GWEventType eventType = o as GWEventType;
                if (eventType != null)
                {
                    fieldList.Add(eventType);
                }
            }
            return(fieldList.ToArray());
        }