Beispiel #1
0
        void FindNext(ref OI _oi, string _s)
        {
            if (_oi.I != null)
            {
                _oi.O = _oi.I.GetValue(_oi.O, null);
            }
            if (_oi.O == null)
            {
                return;
            }
            _oi.I = _oi.O.GetType().GetProperty(FindObjectString(_s), BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance);
            if (_oi.I == null)
            {
                _oi.O = null;
                return;
            }
            if (!FindBraces(_s))
            {
                return;
            }
            _oi.O = _oi.I.GetValue(_oi.O, null);
            _oi.I = null;
            string ssindex = FindIndex(_s);

            if (ssindex == null)
            {
                _oi.O = null;
                return;
            }
            string sindex = FindStringIndex(ssindex);

            if (sindex != null)
            {
                Type         tp      = _oi.O.GetType();
                PropertyInfo pi_item = tp.GetProperty("Item", new Type[] { typeof(string) });
                _oi.O = pi_item.GetValue(_oi.O, new object[] { sindex });

                return;
            }
            int iindex = FindIntIndex(ssindex);

            if (iindex >= 0)
            {
                Type         tp      = _oi.O.GetType();
                PropertyInfo pi_item = tp.GetProperty("Item", new Type[] { typeof(int) });
                _oi.O = pi_item.GetValue(_oi.O, new object[] { iindex });
                return;
            }
            _oi.O = null;
        }
Beispiel #2
0
        public OI(object _root, string _path)
        {
            O = _root;
            if (_path == null)
            {
                return;
            }
            OI oi = new OI();

            oi.O = _root;
            foreach (string s in _path.Split('.'))
            {
                FindNext(ref oi, s);
                if (oi.O == null)
                {
                    O = null;
                    I = null;
                    return;
                }
            }
            O = oi.O;
            I = oi.I;
        }