Example #1
0
        void AddItems(GObject target, string sidePairs)
        {
            string[] arr = sidePairs.Split(jointChar0);
            string   s;
            bool     usePercent;
            int      tid;

            RelationItem newItem = new RelationItem(_owner);

            newItem.target = target;

            int cnt = arr.Length;

            for (int i = 0; i < cnt; i++)
            {
                s = arr[i];
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }

                if (s[s.Length - 1] == '%')
                {
                    s          = s.Substring(0, s.Length - 1);
                    usePercent = true;
                }
                else
                {
                    usePercent = false;
                }

                int j = s.IndexOf("-");
                if (j == -1)
                {
                    s = s + "-" + s;
                }

                tid = Array.IndexOf(RELATION_NAMES, s);
                if (tid == -1)
                {
                    throw new ArgumentException("invalid relation type: " + s);
                }

                newItem.QuickAdd((RelationType)tid, usePercent);
            }

            _items.Add(newItem);
        }
        void AddItems(GObject target, string sidePairs)
        {
            string[] arr = sidePairs.Split(',');
            string s;
            bool usePercent;
            int tid;

            RelationItem newItem = new RelationItem(_owner);
            newItem.target = target;

            int cnt = arr.Length;
            for (int i = 0; i < cnt; i++)
            {
                s = arr[i];
                if (string.IsNullOrEmpty(s))
                    continue;

                if (s[s.Length - 1] == '%')
                {
                    s = s.Substring(0, s.Length - 1);
                    usePercent = true;
                }
                else
                    usePercent = false;

                int j = s.IndexOf("-");
                if (j == -1)
                    s = s + "-" + s;

                tid = Array.IndexOf(RELATION_NAMES, s);
                if (tid == -1)
                    throw new ArgumentException("invalid relation type: " + s);

                newItem.QuickAdd((RelationType)tid, usePercent);
            }

            _items.Add(newItem);
        }