Beispiel #1
0
 public void RemoveRange(int index, int count)
 {
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if (count < 0)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     if (_size - index < count)
     {
         throw new ArgumentException("Argument_InvalidOffLen");
     }
     if (count > 0)
     {
         for (int i = index; i < index + count; i++)
         {
             DataNodeBase node = _items[i].v as DataNodeBase;
             if (node != null)
             {
                 node.onModify = null;
             }
         }
         int size = _size;
         _size -= count;
         if (index < _size)
         {
             Array.Copy(_items, index + count, _items, index, _size - index);
         }
         Array.Clear(_items, _size, count);
         _version++;
         onModify?.Invoke(this, -1);
     }
 }
Beispiel #2
0
        private void OnItemModify(DataNodeBase data)
        {
            int index = IndexOf((T)(object)data);

            if (index < 0)
            {
                return;
            }
            Node n = _items[index];

            if (n.s <= 0)
            {
                n.s           = 1;
                _items[index] = n;
            }
            onModify?.Invoke(this, index);
        }
Beispiel #3
0
        private void OnItemModify(DataNodeBase data)
        {
            int index = IndexOf((T)(object)data);

            if (index < 0)
            {
                return;
            }
            Entry entry = entries[index];

            if (entry.s <= 0)
            {
                entry.s        = 1;
                entries[index] = entry;
            }
            onModify?.Invoke(this, entry.key);
        }
Beispiel #4
0
        private void TryClearHandlers(object item)
        {
            DataNodeBase node = item as DataNodeBase;

            if (node != null)
            {
                node.onModify = null; return;
            }
            IRTSList list = item as IRTSList;

            if (list != null)
            {
                list.onModify = null; return;
            }
            IRTSDict dict = item as IRTSDict;

            if (dict != null)
            {
                dict.onModify = null; return;
            }
        }
Beispiel #5
0
            void SerializeObject(DataNodeBase obj, bool list2dict, bool perfectPrint)
            {
                NodeTypeFieldData data = NodeTypeFieldData.GetNodeTypeFieldData(obj.GetType());

                NodeTypeFieldData.FieldData[] fields = data.GetFields();
                bool first = true;

                if (perfectPrint)
                {
                    builder.Append(indent);
                }
                builder.Append('{');
                indent = indent + "    ";

                foreach (NodeTypeFieldData.FieldData field in fields)
                {
                    if (!first)
                    {
                        builder.Append(',');
                    }
                    if (perfectPrint)
                    {
                        builder.AppendLine();
                        builder.Append(indent);
                    }
                    SerializeString(field.name);
                    builder.Append(':');
                    SerializeValue(false, field.field.GetValue(obj), list2dict, perfectPrint);
                    first = false;
                }
                indent = indent.Substring(4);
                if (perfectPrint)
                {
                    builder.AppendLine();
                    builder.Append(indent);
                }
                builder.Append('}');
            }
Beispiel #6
0
        private void TryRegisterHandler(object item)
        {
            DataNodeBase node = item as DataNodeBase;

            if (node != null)
            {
                node.onModify = mOnItemModify;
                return;
            }
            IRTSList list = item as IRTSList;

            if (list != null)
            {
                list.onModify = mOnListItemModify;
                return;
            }
            IRTSDict dict = item as IRTSDict;

            if (dict != null)
            {
                dict.onModify = mOnDictItemModify;
            }
        }