示例#1
0
        public static void RemoveTest()
        {
            var valueList = new ValueList <int>(new int[] { 1, 2, 3 });

            Assert.That(() => valueList.Remove(1),
                        Is.True
                        );

            Assert.That(() => valueList,
                        Has.Property("Capacity").EqualTo(3)
                        .And.Count.EqualTo(2)
                        );

            Assert.That(() => valueList[0],
                        Is.EqualTo(2)
                        );

            Assert.That(() => valueList[1],
                        Is.EqualTo(3)
                        );

            Assert.That(() => valueList.Remove(0),
                        Is.False
                        );

            valueList = new ValueList <int>();

            Assert.That(() => valueList.Remove(0),
                        Is.False
                        );
        }
示例#2
0
        // Finds the next value that is in the future and removes old values from the list
        private uint FindNextValue()
        {
            List <uint> oldKeys     = new List <uint>();
            uint        foundKey    = 0;
            uint        CurrentTick = GameClock.GetRemoteTick();

            // Find the next value
            foreach (uint key in ValueList.Keys)
            {
                if (key > CurrentTick)
                {
                    foundKey = key;
                    break;
                }

                oldKeys.Add(key);
                LastClockedValue = new KeyValuePair <uint, T>(key, GetValueForTick(key));
            }

            // Remove old
            if (oldKeys.Count > 0)
            {
                oldKeys.ForEach(k => ValueList.Remove(k));
            }

            return(foundKey);
        }
示例#3
0
        public override void CheckForValueUpdate()
        {
            // Check if we are the owner of this
            if (ShouldReplicate())
            {
                return;
            }

            uint RemoteTick   = GameClock.GetRemoteTick();
            bool ValueChanged = false;

            // Find the most recent update
            List <uint> touchedKeys = new List <uint>();

            foreach (uint key in ValueList.Keys)
            {
                if (key > RemoteTick)
                {
                    break;
                }

                ValueList[key].ForEach(parameters => GetCommandReplicator().MDProcessCommand((object[])parameters));
                ValueChanged = true;
                touchedKeys.Add(key);
            }

            if (ValueChanged)
            {
                // Remove old
                touchedKeys.ForEach(k => ValueList.Remove(k));

                // Send event
                CallOnChangeCallback();
            }
        }
示例#4
0
    /// <summary>Removes the first occurence of an item from the pool.</summary>
    /// <param name="item">The item to remove from the pool.</param>
    /// <returns><c>true</c> if <paramref name="item" /> was removed from the pool; otherwise, <c>false</c>.</returns>
    public bool Remove(T item)
    {
        var result = _items.Remove(item);

        if (result)
        {
            _ = _availableItems.Remove(item);
        }

        return(result);
    }
示例#5
0
 public void RemoveValue(EnumItem value)
 {
     ValueList.Remove(value);
 }
示例#6
0
    public bool Add(Ext.Net.Component wrapperComponent, string tableName, string[] parameters, string [] values)
    {
        try
        {
            string sql = "insert into " + tableName + "({0}) values({1})";

            for (int i = 0; i < parameters.Count(); i++)
            {
                if (!string.IsNullOrEmpty(parameters[i]))
                {
                    ColumnName  += "[" + parameters[i] + "],";
                    ValueList   += "N'" + values[i] + "',";
                    UpdateQuery += "[" + parameters[i] + "] = N'" + values[i] + "',";
                }
            }
            GetChildControl(wrapperComponent);
            //     sql = string.Format(sql, ColumnName.Remove(ColumnName.LastIndexOf(",")), ValueList.Remove(ValueList.LastIndexOf(",")));
            return(DataController.DataHandler.GetInstance().ExecuteNonQuery(string.Format(sql, ColumnName.Remove(ColumnName.LastIndexOf(",")), ValueList.Remove(ValueList.LastIndexOf(",")))) > 0);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
示例#7
0
    /// <summary>
    /// Tiến hành insert một bản ghi vào CSDL
    /// </summary>
    /// <param name="wrapperComponent">container chứa các control</param>
    /// <param name="tableName">Tên bảng muốn insert</param>
    /// <returns></returns>
    ///

    public bool Add(Ext.Net.Component wrapperComponent, string tableName)
    {
        try
        {
            string sql = "insert into " + tableName + "({0}) values({1})";
            GetChildControl(wrapperComponent);
            //     sql = string.Format(sql, ColumnName.Remove(ColumnName.LastIndexOf(",")), ValueList.Remove(ValueList.LastIndexOf(",")));
            return(DataController.DataHandler.GetInstance().ExecuteNonQuery(string.Format(sql, ColumnName.Remove(ColumnName.LastIndexOf(",")), ValueList.Remove(ValueList.LastIndexOf(",")))) > 0);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
示例#8
0
 public void Remove()
 {
     var test = new ValueList<ValueInt>(() => ValueInt.GetValues(5));
     test.Insert(0, 4, 0);
     test.Remove(4, 0, 0);
 }