55// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
66
77using System . Buffers . Binary ;
8+ using GameFrameX . Foundation . Localization . Core ;
9+ using GameFrameX . Foundation . Extensions . Localization ;
810
911namespace GameFrameX . Foundation . Extensions ;
1012
@@ -26,7 +28,7 @@ public static uint ReadUIntBigEndianValue(this ReadOnlySpan<byte> buffer, ref in
2628
2729 if ( offset + ConstBaseTypeSize . UIntSize > buffer . Length )
2830 {
29- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
31+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
3032 }
3133
3234 var value = BinaryPrimitives . ReadUInt32BigEndian ( buffer [ offset ..] ) ;
@@ -47,7 +49,7 @@ public static int ReadIntBigEndianValue(this ReadOnlySpan<byte> buffer, ref int
4749
4850 if ( offset + ConstBaseTypeSize . IntSize > buffer . Length )
4951 {
50- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
52+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
5153 }
5254
5355 var value = BinaryPrimitives . ReadInt32BigEndian ( buffer [ offset ..] ) ;
@@ -68,7 +70,7 @@ public static ulong ReadULongBigEndianValue(this ReadOnlySpan<byte> buffer, ref
6870
6971 if ( offset + ConstBaseTypeSize . ULongSize > buffer . Length )
7072 {
71- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
73+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
7274 }
7375
7476 var value = BinaryPrimitives . ReadUInt64BigEndian ( buffer [ offset ..] ) ;
@@ -89,7 +91,7 @@ public static long ReadLongBigEndianValue(this ReadOnlySpan<byte> buffer, ref in
8991
9092 if ( offset + ConstBaseTypeSize . LongSize > buffer . Length )
9193 {
92- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
94+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
9395 }
9496
9597 var value = BinaryPrimitives . ReadInt64BigEndian ( buffer [ offset ..] ) ;
@@ -110,7 +112,7 @@ public static ushort ReadUShortBigEndianValue(this ReadOnlySpan<byte> buffer, re
110112
111113 if ( offset + ConstBaseTypeSize . UShortSize > buffer . Length )
112114 {
113- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
115+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
114116 }
115117
116118 var value = BinaryPrimitives . ReadUInt16BigEndian ( buffer [ offset ..] ) ;
@@ -131,7 +133,7 @@ public static short ReadShortBigEndianValue(this ReadOnlySpan<byte> buffer, ref
131133
132134 if ( offset + ConstBaseTypeSize . ShortSize > buffer . Length )
133135 {
134- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
136+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
135137 }
136138
137139 var value = BinaryPrimitives . ReadInt16BigEndian ( buffer [ offset ..] ) ;
@@ -152,7 +154,7 @@ public static float ReadFloatBigEndianValue(this ReadOnlySpan<byte> buffer, ref
152154
153155 if ( offset + ConstBaseTypeSize . FloatSize > buffer . Length )
154156 {
155- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
157+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
156158 }
157159
158160 var value = BinaryPrimitives . ReadSingleBigEndian ( buffer [ offset ..] ) ;
@@ -173,7 +175,7 @@ public static double ReadDoubleBigEndianValue(this ReadOnlySpan<byte> buffer, re
173175
174176 if ( offset + ConstBaseTypeSize . DoubleSize > buffer . Length )
175177 {
176- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
178+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
177179 }
178180
179181 var value = BinaryPrimitives . ReadDoubleBigEndian ( buffer [ offset ..] ) ;
@@ -194,7 +196,7 @@ public static uint ReadUIntLittleEndianValue(this ReadOnlySpan<byte> buffer, ref
194196
195197 if ( offset + ConstBaseTypeSize . UIntSize > buffer . Length )
196198 {
197- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
199+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
198200 }
199201
200202 var value = BinaryPrimitives . ReadUInt32LittleEndian ( buffer [ offset ..] ) ;
@@ -215,7 +217,7 @@ public static int ReadIntLittleEndianValue(this ReadOnlySpan<byte> buffer, ref i
215217
216218 if ( offset + ConstBaseTypeSize . IntSize > buffer . Length )
217219 {
218- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
220+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
219221 }
220222
221223 var value = BinaryPrimitives . ReadInt32LittleEndian ( buffer [ offset ..] ) ;
@@ -236,7 +238,7 @@ public static ulong ReadULongLittleEndianValue(this ReadOnlySpan<byte> buffer, r
236238
237239 if ( offset + ConstBaseTypeSize . ULongSize > buffer . Length )
238240 {
239- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
241+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
240242 }
241243
242244 var value = BinaryPrimitives . ReadUInt64LittleEndian ( buffer [ offset ..] ) ;
@@ -257,7 +259,7 @@ public static long ReadLongLittleEndianValue(this ReadOnlySpan<byte> buffer, ref
257259
258260 if ( offset + ConstBaseTypeSize . LongSize > buffer . Length )
259261 {
260- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
262+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
261263 }
262264
263265 var value = BinaryPrimitives . ReadInt64LittleEndian ( buffer [ offset ..] ) ;
@@ -278,7 +280,7 @@ public static ushort ReadUShortLittleEndianValue(this ReadOnlySpan<byte> buffer,
278280
279281 if ( offset + ConstBaseTypeSize . UShortSize > buffer . Length )
280282 {
281- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
283+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
282284 }
283285
284286 var value = BinaryPrimitives . ReadUInt16LittleEndian ( buffer [ offset ..] ) ;
@@ -299,7 +301,7 @@ public static short ReadShortLittleEndianValue(this ReadOnlySpan<byte> buffer, r
299301
300302 if ( offset + ConstBaseTypeSize . ShortSize > buffer . Length )
301303 {
302- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
304+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
303305 }
304306
305307 var value = BinaryPrimitives . ReadInt16LittleEndian ( buffer [ offset ..] ) ;
@@ -320,7 +322,7 @@ public static float ReadFloatLittleEndianValue(this ReadOnlySpan<byte> buffer, r
320322
321323 if ( offset + ConstBaseTypeSize . FloatSize > buffer . Length )
322324 {
323- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
325+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
324326 }
325327
326328 var value = BinaryPrimitives . ReadSingleLittleEndian ( buffer [ offset ..] ) ;
@@ -341,7 +343,7 @@ public static double ReadDoubleLittleEndianValue(this ReadOnlySpan<byte> buffer,
341343
342344 if ( offset + ConstBaseTypeSize . DoubleSize > buffer . Length )
343345 {
344- throw new ArgumentOutOfRangeException ( nameof ( offset ) , "Offset is outside the bounds of the buffer." ) ;
346+ throw new ArgumentOutOfRangeException ( nameof ( offset ) , LocalizationService . GetString ( LocalizationKeys . Exceptions . OffsetOutsideBufferBoundsSimple ) ) ;
345347 }
346348
347349 var value = BinaryPrimitives . ReadDoubleLittleEndian ( buffer [ offset ..] ) ;
0 commit comments