Merge branch 'main' into webSupport
This commit is contained in:
commit
f5fef07e0c
358 changed files with 2982 additions and 1498 deletions
|
|
@ -71,7 +71,7 @@ namespace Server
|
|||
return 50;
|
||||
}
|
||||
|
||||
if (!(objs[0] is CallPriorityAttribute attr))
|
||||
if (objs[0] is not CallPriorityAttribute attr)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
|
|
|||
1410
Projects/Server/Collections/BitArray.cs
Normal file
1410
Projects/Server/Collections/BitArray.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -13,33 +13,43 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
namespace Server.Collections
|
||||
namespace Server.Collections;
|
||||
|
||||
public static class CollectionThrowStrings
|
||||
{
|
||||
public static class CollectionThrowStrings
|
||||
{
|
||||
public const string ArgumentOutOfRange_Index =
|
||||
"Index was out of range. Must be non-negative and less than the size of the collection.";
|
||||
public const string ArgumentOutOfRange_Index =
|
||||
"Index was out of range. Must be non-negative and less than the size of the collection.";
|
||||
|
||||
public const string ArgumentOutOfRange_NeedNonNegNum = "Non-negative number required.";
|
||||
public const string ArgumentOutOfRange_NeedNonNegNum = "Non-negative number required.";
|
||||
|
||||
public const string Argument_InvalidOffLen =
|
||||
"Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.";
|
||||
public const string Argument_InvalidOffLen =
|
||||
"Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.";
|
||||
|
||||
public const string Argument_AddingDuplicate = "An item with the same value has already been added. Value: {0}";
|
||||
public const string Argument_AddingDuplicate = "An item with the same value has already been added. Value: {0}";
|
||||
|
||||
public const string Arg_ArrayPlusOffTooSmall =
|
||||
"Destination array is not long enough to copy all the items in the collection. Check array index and length.";
|
||||
public const string Arg_ArrayPlusOffTooSmall =
|
||||
"Destination array is not long enough to copy all the items in the collection. Check array index and length.";
|
||||
|
||||
public const string InvalidOperation_ConcurrentOperationsNotSupported =
|
||||
"Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.";
|
||||
public const string InvalidOperation_ConcurrentOperationsNotSupported =
|
||||
"Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.";
|
||||
|
||||
public const string InvalidOperation_EnumFailedVersion =
|
||||
"Collection was modified after the enumerator was instantiated.";
|
||||
public const string InvalidOperation_EnumFailedVersion =
|
||||
"Collection was modified after the enumerator was instantiated.";
|
||||
|
||||
public const string InvalidOperation_EmptyQueue = "Queue empty.";
|
||||
public const string InvalidOperation_EmptyQueue = "Queue empty.";
|
||||
|
||||
public const string InvalidOperation_EnumNotStarted = "Enumeration has not started. Call MoveNext.";
|
||||
public const string InvalidOperation_EnumNotStarted = "Enumeration has not started. Call MoveNext.";
|
||||
|
||||
public const string InvalidOperation_EnumEnded = "Enumeration already finished.";
|
||||
}
|
||||
public const string InvalidOperation_EnumEnded = "Enumeration already finished.";
|
||||
|
||||
public const string Argument_ArrayTooLarge =
|
||||
"The input array length must not exceed Int32.MaxValue / {0}. Otherwise BitArray.Length would exceed Int32.MaxValue.";
|
||||
|
||||
public const string Arg_ArrayLengthsDiffer = "Array lengths must be the same.";
|
||||
|
||||
public const string Arg_RankMultiDimNotSupported =
|
||||
"Only single dimensional arrays are supported for the requested action.";
|
||||
|
||||
public const string Arg_BitArrayTypeUnsupported =
|
||||
"Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[].";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ namespace Server.Collections
|
|||
|
||||
private void ThrowEnumerationNotStartedOrEnded()
|
||||
{
|
||||
Debug.Assert(_index == -1 || _index == -2);
|
||||
Debug.Assert(_index is -1 or -2);
|
||||
throw new InvalidOperationException(_index == -1 ? CollectionThrowStrings.InvalidOperation_EnumNotStarted : CollectionThrowStrings.InvalidOperation_EnumEnded);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace Server.ContextMenus
|
|||
for (var i = 0; i < Entries.Length; ++i)
|
||||
{
|
||||
var number = Entries[i].Number;
|
||||
if (number < 3000000 || number > 3032767)
|
||||
if (number is < 3000000 or > 3032767)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ namespace Server.Items
|
|||
return container.CheckHold(m, item, message, checkItems, plusItems, plusWeight);
|
||||
}
|
||||
|
||||
if (!(parent is Item parentItem))
|
||||
if (parent is not Item parentItem)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
@ -504,7 +504,7 @@ namespace Server.Items
|
|||
{
|
||||
var item = list[i];
|
||||
|
||||
if (!(item is Container) && CheckHold(from, dropped, false, false) &&
|
||||
if (item is not Container && CheckHold(from, dropped, false, false) &&
|
||||
item.StackWith(from, dropped, playSound))
|
||||
{
|
||||
return true;
|
||||
|
|
@ -540,7 +540,7 @@ namespace Server.Items
|
|||
{
|
||||
var item = list[j];
|
||||
|
||||
if (!(item is Container) && CheckHold(from, dropped, false, false, 0, extraWeight) &&
|
||||
if (item is not Container && CheckHold(from, dropped, false, false, 0, extraWeight) &&
|
||||
item.CanStackWith(dropped))
|
||||
{
|
||||
stackItems.Add(new ItemStackEntry(item, dropped));
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ namespace Server
|
|||
|
||||
var weight = TileData.ItemTable[m_ItemID].Weight;
|
||||
|
||||
if (weight == 255 || weight == 0)
|
||||
if (weight is 255 or 0)
|
||||
{
|
||||
weight = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ namespace Server.Json
|
|||
|
||||
reader.Read();
|
||||
|
||||
if (key == "start" || key == "end")
|
||||
if (key is "start" or "end")
|
||||
{
|
||||
if (objType > -1 && objType != 2)
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ namespace Server.Json
|
|||
|
||||
objType = 1;
|
||||
data[i - 10] = reader.GetInt32();
|
||||
if (i == 12 || i == 15)
|
||||
if (i is 12 or 15)
|
||||
{
|
||||
hasZ = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ namespace Server
|
|||
var eable = map.GetItemsInRange(new Point3D(x, y, 0), 0);
|
||||
|
||||
pool.AddRange(
|
||||
eable.Where(item => item.ItemID <= TileData.MaxItemValue && !(item is BaseMulti))
|
||||
eable.Where(item => item.ItemID <= TileData.MaxItemValue && item is not BaseMulti)
|
||||
.OrderBy(item => item.Z)
|
||||
.Take(pool.Capacity)
|
||||
);
|
||||
|
|
@ -715,7 +715,7 @@ namespace Server
|
|||
{
|
||||
var item = sector.Items[i];
|
||||
|
||||
if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(p.X, p.Y) &&
|
||||
if (item is not BaseMulti && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(p.X, p.Y) &&
|
||||
!item.Movable)
|
||||
{
|
||||
var id = item.ItemData;
|
||||
|
|
@ -1145,7 +1145,7 @@ namespace Server
|
|||
{
|
||||
var item = items[i];
|
||||
|
||||
if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y))
|
||||
if (item is not BaseMulti && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y))
|
||||
{
|
||||
var id = item.ItemData;
|
||||
surface = id.Surface;
|
||||
|
|
|
|||
|
|
@ -1888,7 +1888,7 @@ namespace Server
|
|||
|
||||
item ??= FindItemOnLayer(Layer.Mount);
|
||||
|
||||
if (!(item is IMountItem mountItem))
|
||||
if (item is not IMountItem mountItem)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
@ -8397,7 +8397,7 @@ namespace Server
|
|||
|
||||
var n = Notoriety.Compute(this, target);
|
||||
|
||||
return n == Notoriety.Criminal || n == Notoriety.Murderer;
|
||||
return n is Notoriety.Criminal or Notoriety.Murderer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ namespace Server.Network
|
|||
|
||||
private void SetPacketTime(int packetID)
|
||||
{
|
||||
if (packetID < 0 || packetID >= 0x100)
|
||||
if (packetID is < 0 or >= 0x100)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ namespace Server.Network
|
|||
|
||||
public long GetPacketDelay(int packetID)
|
||||
{
|
||||
if (packetID < 0 || packetID >= 0x100)
|
||||
if (packetID is < 0 or >= 0x100)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -243,7 +243,7 @@ namespace Server.Network
|
|||
|
||||
private void UpdatePacketCount(int packetID)
|
||||
{
|
||||
if (packetID < 0 || packetID >= 0x100)
|
||||
if (packetID is < 0 or >= 0x100)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -728,7 +728,7 @@ namespace Server.Network
|
|||
{
|
||||
reader.Advance((uint)packetLength);
|
||||
}
|
||||
else if (_parserState == ParserState.AwaitingPartialPacket || _parserState == ParserState.Throttled)
|
||||
else if (_parserState is ParserState.AwaitingPartialPacket or ParserState.Throttled)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Server.Network
|
|||
reader.ReadInt16(); // font
|
||||
var text = reader.ReadAsciiSafe().Trim();
|
||||
|
||||
if (text.Length <= 0 || text.Length > 128)
|
||||
if (text.Length is <= 0 or > 128)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ namespace Server.Network
|
|||
var count = (value & 0xFFF0) >> 4;
|
||||
var hold = value & 0xF;
|
||||
|
||||
if (count < 0 || count > 50)
|
||||
if (count is < 0 or > 50)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ namespace Server.Network
|
|||
|
||||
text = text.Trim();
|
||||
|
||||
if (text.Length <= 0 || text.Length > 128)
|
||||
if (text.Length is <= 0 or > 128)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.Collections;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
@ -78,6 +79,15 @@ namespace Server
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int Read(Span<byte> buffer) => _reader.Read(buffer);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public BitArray ReadBitArray()
|
||||
{
|
||||
var length = ((IGenericReader)this).ReadEncodedInt();
|
||||
|
||||
// BinaryReader doesn't expose a Span slice of the buffer, so we use a custom ctor
|
||||
return new BitArray(_reader, length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public long Seek(long offset, SeekOrigin origin) => _reader.BaseStream.Seek(offset, origin);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Server.Collections;
|
||||
using Server.Text;
|
||||
|
||||
namespace Server
|
||||
|
|
@ -156,6 +157,19 @@ namespace Server
|
|||
return length;
|
||||
}
|
||||
|
||||
public BitArray ReadBitArray()
|
||||
{
|
||||
var length = ((IGenericReader)this).ReadEncodedInt();
|
||||
if (length > _buffer.Length - _position)
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
}
|
||||
|
||||
var bitArray = new BitArray(_buffer.AsSpan(_position, length));
|
||||
_position += length;
|
||||
return bitArray;
|
||||
}
|
||||
|
||||
public virtual long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
Debug.Assert(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Server.Collections;
|
||||
using Server.Text;
|
||||
|
||||
namespace Server
|
||||
|
|
@ -134,6 +135,16 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public void Write(BitArray bitArray)
|
||||
{
|
||||
var byteLength = BitArray.GetByteArrayLengthFromBitLength(bitArray.Length);
|
||||
FlushIfNeeded(byteLength + 4);
|
||||
|
||||
((IGenericWriter)this).WriteEncodedInt(byteLength);
|
||||
bitArray.CopyTo(_buffer.AsSpan((int)Index, byteLength));
|
||||
Index += byteLength;
|
||||
}
|
||||
|
||||
public virtual long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
Debug.Assert(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Server.Collections;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
@ -116,6 +117,8 @@ namespace Server
|
|||
return new Guid(bytes);
|
||||
}
|
||||
|
||||
BitArray ReadBitArray();
|
||||
|
||||
long Seek(long offset, SeekOrigin origin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Server.Collections;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
@ -160,6 +161,8 @@ namespace Server
|
|||
Write(stack);
|
||||
}
|
||||
|
||||
void Write(BitArray bitArray);
|
||||
|
||||
long Seek(long offset, SeekOrigin origin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SerializationGenerator\SerializationGenerator.csproj">
|
||||
<SetTargetFramework>TargetFramework=netstandard2.1</SetTargetFramework>
|
||||
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
|
||||
<OutputItemType>Analyzer</OutputItemType>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
if (Lock < SkillLock.Up || Lock > SkillLock.Locked)
|
||||
if (Lock is < SkillLock.Up or > SkillLock.Locked)
|
||||
{
|
||||
Console.WriteLine("Bad skill lock -> {0}.{1}", owner.Owner, Lock);
|
||||
Lock = SkillLock.Up;
|
||||
|
|
@ -323,7 +323,7 @@ namespace Server
|
|||
|
||||
public void SetLockNoRelay(SkillLock skillLock)
|
||||
{
|
||||
if (skillLock < SkillLock.Up || skillLock > SkillLock.Locked)
|
||||
if (skillLock is < SkillLock.Up or > SkillLock.Locked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
242
Projects/Server/Timer/Timer.DelayStateCall.cs
Normal file
242
Projects/Server/Timer/Timer.DelayStateCall.cs
Normal file
|
|
@ -0,0 +1,242 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2021 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Timer.DelayStateCall.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public partial class Timer
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T>(Action<T> callback, T state) =>
|
||||
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, state);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T>(TimeSpan delay, Action<T> callback, T state) =>
|
||||
DelayCall(delay, TimeSpan.Zero, 1, callback, state);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T>(TimeSpan delay, TimeSpan interval, Action<T> callback, T state) =>
|
||||
DelayCall(delay, interval, 0, callback, state);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T>(TimeSpan delay, TimeSpan interval, int count, Action<T> callback, T state) =>
|
||||
new DelayStateCallTimer<T>(delay, interval, count, callback, state).Start();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2>(Action<T1, T2> callback, T1 t1, T2 t2) =>
|
||||
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2>(TimeSpan delay, Action<T1, T2> callback, T1 t1, T2 t2) =>
|
||||
DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2>(TimeSpan delay, TimeSpan interval, Action<T1, T2> callback, T1 t1, T2 t2) =>
|
||||
DelayCall(delay, interval, 0, callback, t1, t2);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2>(
|
||||
TimeSpan delay, TimeSpan interval, int count, Action<T1, T2> callback,
|
||||
T1 t1, T2 t2
|
||||
) => new DelayStateCallTimer<T1, T2>(delay, interval, count, callback, t1, t2).Start();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3>(Action<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3) =>
|
||||
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3>(
|
||||
TimeSpan delay, Action<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3
|
||||
) => DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2, t3);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3>(
|
||||
TimeSpan delay, TimeSpan interval, Action<T1, T2, T3> callback,
|
||||
T1 t1, T2 t2, T3 t3
|
||||
) => DelayCall(delay, interval, 0, callback, t1, t2, t3);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3>(
|
||||
TimeSpan delay, TimeSpan interval, int count,
|
||||
Action<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3
|
||||
) => new DelayStateCallTimer<T1, T2, T3>(delay, interval, count, callback, t1, t2, t3).Start();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3, T4>(
|
||||
Action<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) => DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3, t4);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3, T4>(
|
||||
TimeSpan delay, Action<T1, T2, T3, T4> callback,
|
||||
T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) => DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2, t3, t4);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3, T4>(
|
||||
TimeSpan delay, TimeSpan interval,
|
||||
Action<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) => DelayCall(delay, interval, 0, callback, t1, t2, t3, t4);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3, T4>(
|
||||
TimeSpan delay, TimeSpan interval, int count,
|
||||
Action<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) => new DelayStateCallTimer<T1, T2, T3, T4>(delay, interval, count, callback, t1, t2, t3, t4).Start();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3, T4, T5>(
|
||||
Action<T1, T2, T3, T4, T5> callback, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5
|
||||
) => new DelayStateCallTimer<T1, T2, T3, T4, T5>(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3, t4, t5).Start();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3, T4, T5>(
|
||||
TimeSpan delay,
|
||||
Action<T1, T2, T3, T4, T5> callback, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5
|
||||
) => new DelayStateCallTimer<T1, T2, T3, T4, T5>(delay, TimeSpan.Zero, 1, callback, t1, t2, t3, t4, t5).Start();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3, T4, T5>(
|
||||
TimeSpan delay, TimeSpan interval,
|
||||
Action<T1, T2, T3, T4, T5> callback, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5
|
||||
) => new DelayStateCallTimer<T1, T2, T3, T4, T5>(delay, interval, 0, callback, t1, t2, t3, t4, t5).Start();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Timer DelayCall<T1, T2, T3, T4, T5>(
|
||||
TimeSpan delay, TimeSpan interval, int count,
|
||||
Action<T1, T2, T3, T4, T5> callback, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5
|
||||
) => new DelayStateCallTimer<T1, T2, T3, T4, T5>(delay, interval, count, callback, t1, t2, t3, t4, t5).Start();
|
||||
|
||||
private class DelayStateCallTimer<T> : Timer
|
||||
{
|
||||
private readonly T _t1;
|
||||
|
||||
public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, Action<T> callback, T state)
|
||||
: base(delay, interval, count)
|
||||
{
|
||||
Callback = callback;
|
||||
_t1 = state;
|
||||
}
|
||||
|
||||
public Action<T> Callback { get; }
|
||||
|
||||
protected override void OnTick() => Callback?.Invoke(_t1);
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer<T1, T2> : Timer
|
||||
{
|
||||
private readonly T1 _t1;
|
||||
private readonly T2 _t2;
|
||||
|
||||
public DelayStateCallTimer(
|
||||
TimeSpan delay, TimeSpan interval, int count, Action<T1, T2> callback,
|
||||
T1 t1, T2 t2
|
||||
) : base(delay, interval, count)
|
||||
{
|
||||
Callback = callback;
|
||||
_t1 = t1;
|
||||
_t2 = t2;
|
||||
}
|
||||
|
||||
public Action<T1, T2> Callback { get; }
|
||||
|
||||
protected override void OnTick() => Callback?.Invoke(_t1, _t2);
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer<T1, T2, T3> : Timer
|
||||
{
|
||||
private readonly T1 _t1;
|
||||
private readonly T2 _t2;
|
||||
private readonly T3 _t3;
|
||||
|
||||
public DelayStateCallTimer(
|
||||
TimeSpan delay, TimeSpan interval, int count, Action<T1, T2, T3> callback,
|
||||
T1 t1, T2 t2, T3 t3
|
||||
) : base(delay, interval, count)
|
||||
{
|
||||
Callback = callback;
|
||||
_t1 = t1;
|
||||
_t2 = t2;
|
||||
_t3 = t3;
|
||||
}
|
||||
|
||||
public Action<T1, T2, T3> Callback { get; }
|
||||
|
||||
protected override void OnTick() => Callback?.Invoke(_t1, _t2, _t3);
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer<T1, T2, T3, T4> : Timer
|
||||
{
|
||||
private readonly T1 _t1;
|
||||
private readonly T2 _t2;
|
||||
private readonly T3 _t3;
|
||||
private readonly T4 _t4;
|
||||
|
||||
public DelayStateCallTimer(
|
||||
TimeSpan delay, TimeSpan interval, int count, Action<T1, T2, T3, T4> callback,
|
||||
T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) : base(delay, interval, count)
|
||||
{
|
||||
Callback = callback;
|
||||
_t1 = t1;
|
||||
_t2 = t2;
|
||||
_t3 = t3;
|
||||
_t4 = t4;
|
||||
}
|
||||
|
||||
public Action<T1, T2, T3, T4> Callback { get; }
|
||||
|
||||
protected override void OnTick() => Callback?.Invoke(_t1, _t2, _t3, _t4);
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer<T1, T2, T3, T4, T5> : Timer
|
||||
{
|
||||
private readonly T1 _t1;
|
||||
private readonly T2 _t2;
|
||||
private readonly T3 _t3;
|
||||
private readonly T4 _t4;
|
||||
private readonly T5 _t5;
|
||||
|
||||
public DelayStateCallTimer(
|
||||
TimeSpan delay, TimeSpan interval, int count, Action<T1, T2, T3, T4, T5> callback,
|
||||
T1 t1, T2 t2, T3 t3, T4 t4, T5 t5
|
||||
) : base(delay, interval, count)
|
||||
{
|
||||
Callback = callback;
|
||||
_t1 = t1;
|
||||
_t2 = t2;
|
||||
_t3 = t3;
|
||||
_t4 = t4;
|
||||
_t5 = t5;
|
||||
}
|
||||
|
||||
public Action<T1, T2, T3, T4, T5> Callback { get; }
|
||||
|
||||
protected override void OnTick() => Callback?.Invoke(_t1, _t2, _t3, _t4, _t5);
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -343,7 +343,7 @@ namespace Server
|
|||
|
||||
if (endOfSection || i + 1 == end)
|
||||
{
|
||||
if (number < 0 || number > 255)
|
||||
if (number is < 0 or > 255)
|
||||
{
|
||||
valid = false;
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue