Core/Refactor: Part 2
This commit is contained in:
@@ -29,13 +29,13 @@ namespace System.Collections
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
m_array = new uint[GetArrayLength(length, BitsPerInt32)];
|
||||
m_length = length;
|
||||
_mArray = new uint[GetArrayLength(length, BitsPerInt32)];
|
||||
_mLength = length;
|
||||
|
||||
uint fillValue = defaultValue ? 0xffffffff : 0;
|
||||
for (int i = 0; i < m_array.Length; i++)
|
||||
for (int i = 0; i < _mArray.Length; i++)
|
||||
{
|
||||
m_array[i] = fillValue;
|
||||
_mArray[i] = fillValue;
|
||||
}
|
||||
|
||||
_version = 0;
|
||||
@@ -54,10 +54,10 @@ namespace System.Collections
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
m_array = new uint[values.Length];
|
||||
m_length = values.Length * BitsPerInt32;
|
||||
_mArray = new uint[values.Length];
|
||||
_mLength = values.Length * BitsPerInt32;
|
||||
|
||||
Array.Copy(values, m_array, values.Length);
|
||||
Array.Copy(values, _mArray, values.Length);
|
||||
|
||||
_version = 0;
|
||||
}
|
||||
@@ -70,11 +70,11 @@ namespace System.Collections
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int arrayLength = GetArrayLength(bits.m_length, BitsPerInt32);
|
||||
m_array = new uint[arrayLength];
|
||||
m_length = bits.m_length;
|
||||
int arrayLength = GetArrayLength(bits._mLength, BitsPerInt32);
|
||||
_mArray = new uint[arrayLength];
|
||||
_mLength = bits._mLength;
|
||||
|
||||
Array.Copy(bits.m_array, m_array, arrayLength);
|
||||
Array.Copy(bits._mArray, _mArray, arrayLength);
|
||||
|
||||
_version = bits._version;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace System.Collections
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
|
||||
return (Convert.ToInt64(m_array[index / 32]) & (1 << (index % 32))) != 0;
|
||||
return (Convert.ToInt64(_mArray[index / 32]) & (1 << (index % 32))) != 0;
|
||||
}
|
||||
|
||||
public void Set(int index, bool value)
|
||||
@@ -112,11 +112,11 @@ namespace System.Collections
|
||||
|
||||
if (value)
|
||||
{
|
||||
m_array[index / 32] |= (1u << (index % 32));
|
||||
_mArray[index / 32] |= (1u << (index % 32));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_array[index / 32] &= ~(1u << (index % 32));
|
||||
_mArray[index / 32] &= ~(1u << (index % 32));
|
||||
}
|
||||
|
||||
_version++;
|
||||
@@ -125,10 +125,10 @@ namespace System.Collections
|
||||
public void SetAll(bool value)
|
||||
{
|
||||
uint fillValue = value ? 0xffffffff : 0u;
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
int ints = GetArrayLength(_mLength, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] = fillValue;
|
||||
_mArray[i] = fillValue;
|
||||
}
|
||||
|
||||
_version++;
|
||||
@@ -142,10 +142,10 @@ namespace System.Collections
|
||||
throw new ArgumentException();
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
int ints = GetArrayLength(_mLength, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] &= value.m_array[i];
|
||||
_mArray[i] &= value._mArray[i];
|
||||
}
|
||||
|
||||
_version++;
|
||||
@@ -160,10 +160,10 @@ namespace System.Collections
|
||||
throw new ArgumentException();
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
int ints = GetArrayLength(_mLength, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] |= value.m_array[i];
|
||||
_mArray[i] |= value._mArray[i];
|
||||
}
|
||||
|
||||
_version++;
|
||||
@@ -178,10 +178,10 @@ namespace System.Collections
|
||||
throw new ArgumentException();
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
int ints = GetArrayLength(_mLength, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] ^= value.m_array[i];
|
||||
_mArray[i] ^= value._mArray[i];
|
||||
}
|
||||
|
||||
_version++;
|
||||
@@ -190,10 +190,10 @@ namespace System.Collections
|
||||
|
||||
public BitSet Not()
|
||||
{
|
||||
int ints = GetArrayLength(m_length, BitsPerInt32);
|
||||
int ints = GetArrayLength(_mLength, BitsPerInt32);
|
||||
for (int i = 0; i < ints; i++)
|
||||
{
|
||||
m_array[i] = ~m_array[i];
|
||||
_mArray[i] = ~_mArray[i];
|
||||
}
|
||||
|
||||
_version++;
|
||||
@@ -205,7 +205,7 @@ namespace System.Collections
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<int>() >= 0);
|
||||
return m_length;
|
||||
return _mLength;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -216,29 +216,29 @@ namespace System.Collections
|
||||
Contract.EndContractBlock();
|
||||
|
||||
int newints = GetArrayLength(value, BitsPerInt32);
|
||||
if (newints > m_array.Length || newints + _ShrinkThreshold < m_array.Length)
|
||||
if (newints > _mArray.Length || newints + ShrinkThreshold < _mArray.Length)
|
||||
{
|
||||
// grow or shrink (if wasting more than _ShrinkThreshold ints)
|
||||
uint[] newarray = new uint[newints];
|
||||
Array.Copy(m_array, newarray, newints > m_array.Length ? m_array.Length : newints);
|
||||
m_array = newarray;
|
||||
Array.Copy(_mArray, newarray, newints > _mArray.Length ? _mArray.Length : newints);
|
||||
_mArray = newarray;
|
||||
}
|
||||
|
||||
if (value > m_length)
|
||||
if (value > _mLength)
|
||||
{
|
||||
// clear high bit values in the last int
|
||||
int last = GetArrayLength(m_length, BitsPerInt32) - 1;
|
||||
int bits = m_length % 32;
|
||||
int last = GetArrayLength(_mLength, BitsPerInt32) - 1;
|
||||
int bits = _mLength % 32;
|
||||
if (bits > 0)
|
||||
{
|
||||
m_array[last] &= (1u << bits) - 1;
|
||||
_mArray[last] &= (1u << bits) - 1;
|
||||
}
|
||||
|
||||
// clear remaining int values
|
||||
Array.Clear(m_array, last + 1, newints - last - 1);
|
||||
Array.Clear(_mArray, last + 1, newints - last - 1);
|
||||
}
|
||||
|
||||
m_length = value;
|
||||
_mLength = value;
|
||||
_version++;
|
||||
}
|
||||
}
|
||||
@@ -259,26 +259,26 @@ namespace System.Collections
|
||||
|
||||
if (array is uint[])
|
||||
{
|
||||
Array.Copy(m_array, 0, array, index, GetArrayLength(m_length, BitsPerInt32));
|
||||
Array.Copy(_mArray, 0, array, index, GetArrayLength(_mLength, BitsPerInt32));
|
||||
}
|
||||
else if (array is byte[])
|
||||
{
|
||||
int arrayLength = GetArrayLength(m_length, BitsPerByte);
|
||||
int arrayLength = GetArrayLength(_mLength, BitsPerByte);
|
||||
if ((array.Length - index) < arrayLength)
|
||||
throw new ArgumentException();
|
||||
|
||||
byte[] b = (byte[])array;
|
||||
for (int i = 0; i < arrayLength; i++)
|
||||
b[index + i] = (byte)((m_array[i / 4] >> ((i % 4) * 8)) & 0x000000FF); // Shift to bring the required byte to LSB, then mask
|
||||
b[index + i] = (byte)((_mArray[i / 4] >> ((i % 4) * 8)) & 0x000000FF); // Shift to bring the required byte to LSB, then mask
|
||||
}
|
||||
else if (array is bool[])
|
||||
{
|
||||
if (array.Length - index < m_length)
|
||||
if (array.Length - index < _mLength)
|
||||
throw new ArgumentException();
|
||||
|
||||
bool[] b = (bool[])array;
|
||||
for (int i = 0; i < m_length; i++)
|
||||
b[index + i] = ((m_array[i / 32] >> (i % 32)) & 0x00000001) != 0;
|
||||
for (int i = 0; i < _mLength; i++)
|
||||
b[index + i] = ((_mArray[i / 32] >> (i % 32)) & 0x00000001) != 0;
|
||||
}
|
||||
else
|
||||
throw new ArgumentException();
|
||||
@@ -290,7 +290,7 @@ namespace System.Collections
|
||||
{
|
||||
Contract.Ensures(Contract.Result<int>() >= 0);
|
||||
|
||||
return (int)m_length;
|
||||
return (int)_mLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,9 +299,9 @@ namespace System.Collections
|
||||
Contract.Ensures(Contract.Result<Object>() != null);
|
||||
Contract.Ensures(((BitArray)Contract.Result<Object>()).Length == this.Length);
|
||||
|
||||
BitSet bitArray = new BitSet(m_array);
|
||||
BitSet bitArray = new BitSet(_mArray);
|
||||
bitArray._version = _version;
|
||||
bitArray.m_length = m_length;
|
||||
bitArray._mLength = _mLength;
|
||||
return bitArray;
|
||||
}
|
||||
|
||||
@@ -352,16 +352,16 @@ namespace System.Collections
|
||||
[Serializable]
|
||||
private class BitArrayEnumeratorSimple : IEnumerator, ICloneable
|
||||
{
|
||||
private BitSet bitarray;
|
||||
private int index;
|
||||
private int version;
|
||||
private bool currentElement;
|
||||
private BitSet _bitarray;
|
||||
private int _index;
|
||||
private int _version;
|
||||
private bool _currentElement;
|
||||
|
||||
internal BitArrayEnumeratorSimple(BitSet bitarray)
|
||||
{
|
||||
this.bitarray = bitarray;
|
||||
this.index = -1;
|
||||
version = bitarray._version;
|
||||
this._bitarray = bitarray;
|
||||
_index = -1;
|
||||
_version = bitarray._version;
|
||||
}
|
||||
|
||||
public Object Clone()
|
||||
@@ -372,14 +372,14 @@ namespace System.Collections
|
||||
public bool MoveNext()
|
||||
{
|
||||
//if (version != bitarray._version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
|
||||
if (index < (bitarray.Count - 1))
|
||||
if (_index < (_bitarray.Count - 1))
|
||||
{
|
||||
index++;
|
||||
currentElement = bitarray.Get(index);
|
||||
_index++;
|
||||
_currentElement = _bitarray.Get(_index);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
index = bitarray.Count;
|
||||
_index = _bitarray.Count;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -388,27 +388,27 @@ namespace System.Collections
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index == -1)
|
||||
if (_index == -1)
|
||||
throw new InvalidOperationException();
|
||||
if (index >= bitarray.Count)
|
||||
if (_index >= _bitarray.Count)
|
||||
throw new InvalidOperationException();
|
||||
return currentElement;
|
||||
return _currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
//if (version != bitarray._version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion));
|
||||
index = -1;
|
||||
_index = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private uint[] m_array;
|
||||
private int m_length;
|
||||
private uint[] _mArray;
|
||||
private int _mLength;
|
||||
private int _version;
|
||||
[NonSerialized]
|
||||
private Object _syncRoot;
|
||||
|
||||
private const int _ShrinkThreshold = 256;
|
||||
private const int ShrinkThreshold = 256;
|
||||
}
|
||||
}
|
||||
@@ -19,84 +19,84 @@ namespace Framework.Collections
|
||||
{
|
||||
public class LinkedListElement
|
||||
{
|
||||
internal LinkedListElement iNext;
|
||||
internal LinkedListElement iPrev;
|
||||
internal LinkedListElement INext;
|
||||
internal LinkedListElement IPrev;
|
||||
|
||||
public LinkedListElement()
|
||||
{
|
||||
iNext = iPrev = null;
|
||||
INext = IPrev = null;
|
||||
}
|
||||
|
||||
~LinkedListElement() { delink(); }
|
||||
~LinkedListElement() { Delink(); }
|
||||
|
||||
bool hasNext() { return (iNext != null && iNext.iNext != null); }
|
||||
bool hasPrev() { return (iPrev != null && iPrev.iPrev != null); }
|
||||
public bool isInList() { return (iNext != null && iPrev != null); }
|
||||
bool HasNext() { return (INext != null && INext.INext != null); }
|
||||
bool HasPrev() { return (IPrev != null && IPrev.IPrev != null); }
|
||||
public bool IsInList() { return (INext != null && IPrev != null); }
|
||||
|
||||
public LinkedListElement GetNextElement() { return hasNext() ? iNext : null; }
|
||||
public LinkedListElement GetPrevElement() { return hasPrev() ? iPrev : null; }
|
||||
public LinkedListElement GetNextElement() { return HasNext() ? INext : null; }
|
||||
public LinkedListElement GetPrevElement() { return HasPrev() ? IPrev : null; }
|
||||
|
||||
public void delink()
|
||||
public void Delink()
|
||||
{
|
||||
if (!isInList())
|
||||
if (!IsInList())
|
||||
return;
|
||||
|
||||
iNext.iPrev = iPrev;
|
||||
iPrev.iNext = iNext;
|
||||
iNext = null;
|
||||
iPrev = null;
|
||||
INext.IPrev = IPrev;
|
||||
IPrev.INext = INext;
|
||||
INext = null;
|
||||
IPrev = null;
|
||||
}
|
||||
|
||||
public void insertBefore(LinkedListElement pElem)
|
||||
public void InsertBefore(LinkedListElement pElem)
|
||||
{
|
||||
pElem.iNext = this;
|
||||
pElem.iPrev = iPrev;
|
||||
iPrev.iNext = pElem;
|
||||
iPrev = pElem;
|
||||
pElem.INext = this;
|
||||
pElem.IPrev = IPrev;
|
||||
IPrev.INext = pElem;
|
||||
IPrev = pElem;
|
||||
}
|
||||
|
||||
public void insertAfter(LinkedListElement pElem)
|
||||
public void InsertAfter(LinkedListElement pElem)
|
||||
{
|
||||
pElem.iPrev = this;
|
||||
pElem.iNext = iNext;
|
||||
iNext.iPrev = pElem;
|
||||
iNext = pElem;
|
||||
pElem.IPrev = this;
|
||||
pElem.INext = INext;
|
||||
INext.IPrev = pElem;
|
||||
INext = pElem;
|
||||
}
|
||||
}
|
||||
|
||||
public class LinkedListHead
|
||||
{
|
||||
LinkedListElement iFirst = new LinkedListElement();
|
||||
LinkedListElement iLast = new LinkedListElement();
|
||||
uint iSize;
|
||||
LinkedListElement _iFirst = new LinkedListElement();
|
||||
LinkedListElement _iLast = new LinkedListElement();
|
||||
uint _iSize;
|
||||
|
||||
public LinkedListHead()
|
||||
{
|
||||
iSize = 0;
|
||||
_iSize = 0;
|
||||
// create empty list
|
||||
|
||||
iFirst.iNext = iLast;
|
||||
iLast.iPrev = iFirst;
|
||||
_iFirst.INext = _iLast;
|
||||
_iLast.IPrev = _iFirst;
|
||||
}
|
||||
|
||||
public bool isEmpty() { return (!iFirst.iNext.isInList()); }
|
||||
public bool IsEmpty() { return (!_iFirst.INext.IsInList()); }
|
||||
|
||||
public LinkedListElement GetFirstElement() { return (isEmpty() ? null : iFirst.iNext); }
|
||||
public LinkedListElement GetLastElement() { return (isEmpty() ? null : iLast.iPrev); }
|
||||
public LinkedListElement GetFirstElement() { return (IsEmpty() ? null : _iFirst.INext); }
|
||||
public LinkedListElement GetLastElement() { return (IsEmpty() ? null : _iLast.IPrev); }
|
||||
|
||||
public void insertFirst(LinkedListElement pElem)
|
||||
public void InsertFirst(LinkedListElement pElem)
|
||||
{
|
||||
iFirst.insertAfter(pElem);
|
||||
_iFirst.InsertAfter(pElem);
|
||||
}
|
||||
|
||||
public void insertLast(LinkedListElement pElem)
|
||||
public void InsertLast(LinkedListElement pElem)
|
||||
{
|
||||
iLast.insertBefore(pElem);
|
||||
_iLast.InsertBefore(pElem);
|
||||
}
|
||||
|
||||
public uint getSize()
|
||||
public uint GetSize()
|
||||
{
|
||||
if (iSize == 0)
|
||||
if (_iSize == 0)
|
||||
{
|
||||
uint result = 0;
|
||||
LinkedListElement e = GetFirstElement();
|
||||
@@ -108,10 +108,10 @@ namespace Framework.Collections
|
||||
return result;
|
||||
}
|
||||
else
|
||||
return iSize;
|
||||
return _iSize;
|
||||
}
|
||||
|
||||
public void incSize() { ++iSize; }
|
||||
public void decSize() { --iSize; }
|
||||
public void IncSize() { ++_iSize; }
|
||||
public void DecSize() { --_iSize; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ namespace Framework.Cryptography
|
||||
|
||||
public void InitializeEncryption<T>(T p, T q, T dp, T dq, T iq, bool isBigEndian = false)
|
||||
{
|
||||
this._p = p.ToBigInteger(isBigEndian);
|
||||
this._q = q.ToBigInteger(isBigEndian);
|
||||
this._dp = dp.ToBigInteger(isBigEndian);
|
||||
this._dq = dq.ToBigInteger(isBigEndian);
|
||||
this._iq = iq.ToBigInteger(isBigEndian);
|
||||
_p = p.ToBigInteger(isBigEndian);
|
||||
_q = q.ToBigInteger(isBigEndian);
|
||||
_dp = dp.ToBigInteger(isBigEndian);
|
||||
_dq = dq.ToBigInteger(isBigEndian);
|
||||
_iq = iq.ToBigInteger(isBigEndian);
|
||||
|
||||
if (this._p.IsZero && this._q.IsZero)
|
||||
if (_p.IsZero && _q.IsZero)
|
||||
throw new InvalidOperationException("'0' isn't allowed for p or q");
|
||||
else
|
||||
_isEncryptionInitialized = true;
|
||||
@@ -43,8 +43,8 @@ namespace Framework.Cryptography
|
||||
|
||||
public void InitializeDecryption<T>(T e, T n, bool reverseBytes = false)
|
||||
{
|
||||
this._e = e.ToBigInteger(reverseBytes);
|
||||
this._n = n.ToBigInteger(reverseBytes);
|
||||
_e = e.ToBigInteger(reverseBytes);
|
||||
_n = n.ToBigInteger(reverseBytes);
|
||||
|
||||
_isDecryptionInitialized = true;
|
||||
}
|
||||
@@ -82,13 +82,13 @@ namespace Framework.Cryptography
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this._e = 0;
|
||||
this._n = 0;
|
||||
this._p = 0;
|
||||
this._q = 0;
|
||||
this._dp = 0;
|
||||
this._dq = 0;
|
||||
this._iq = 0;
|
||||
_e = 0;
|
||||
_n = 0;
|
||||
_p = 0;
|
||||
_q = 0;
|
||||
_dp = 0;
|
||||
_dq = 0;
|
||||
_iq = 0;
|
||||
|
||||
_isEncryptionInitialized = false;
|
||||
_isDecryptionInitialized = false;
|
||||
|
||||
@@ -31,10 +31,7 @@ namespace Framework.Database
|
||||
if (_callbacks.Empty())
|
||||
return;
|
||||
|
||||
_callbacks.RemoveAll(callback =>
|
||||
{
|
||||
return callback.InvokeIfReady() == QueryCallbackStatus.Completed;
|
||||
});
|
||||
_callbacks.RemoveAll(callback => callback.InvokeIfReady() == QueryCallbackStatus.Completed);
|
||||
}
|
||||
|
||||
List<QueryCallback> _callbacks = new List<QueryCallback>();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Framework.Dynamic
|
||||
public void unlink()
|
||||
{
|
||||
targetObjectDestroyLink();
|
||||
delink();
|
||||
Delink();
|
||||
_RefTo = null;
|
||||
_RefFrom = null;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ namespace Framework.Dynamic
|
||||
public void invalidate() // the iRefFrom MUST remain!!
|
||||
{
|
||||
sourceObjectDestroyLink();
|
||||
delink();
|
||||
Delink();
|
||||
_RefTo = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Framework.Dynamic
|
||||
|
||||
public TaskScheduler CancelAll()
|
||||
{
|
||||
/// Clear the task holder
|
||||
// Clear the task holder
|
||||
_task_holder.Clear();
|
||||
_asyncHolder.Clear();
|
||||
return this;
|
||||
@@ -165,10 +165,7 @@ namespace Framework.Dynamic
|
||||
|
||||
public TaskScheduler CancelGroup(uint group)
|
||||
{
|
||||
_task_holder.RemoveIf(task =>
|
||||
{
|
||||
return task.IsInGroup(group);
|
||||
});
|
||||
_task_holder.RemoveIf(task => task.IsInGroup(@group));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -689,10 +686,7 @@ namespace Framework.Dynamic
|
||||
public TaskContext Schedule(TimeSpan time, Action<TaskContext> task)
|
||||
{
|
||||
var end = _task._end;
|
||||
return Dispatch(scheduler =>
|
||||
{
|
||||
return scheduler.ScheduleAt(end, time, task);
|
||||
});
|
||||
return Dispatch(scheduler => scheduler.ScheduleAt(end, time, task));
|
||||
}
|
||||
public TaskContext Schedule(TimeSpan time, Action task) { return Schedule(time, delegate (TaskContext task1) { task(); }); }
|
||||
|
||||
@@ -709,7 +703,7 @@ namespace Framework.Dynamic
|
||||
public TaskContext Schedule(TimeSpan time, uint group, Action<TaskContext> task)
|
||||
{
|
||||
var end = _task._end;
|
||||
return Dispatch(scheduler => { return scheduler.ScheduleAt(end, time, group, task); });
|
||||
return Dispatch(scheduler => scheduler.ScheduleAt(end, time, @group, task));
|
||||
}
|
||||
public TaskContext Schedule(TimeSpan time, uint group, Action task) { return Schedule(time, group, delegate (TaskContext task1) { task(); }); }
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("AxisAlignedBox(Min={0}, Max={1})", _lo, _hi);
|
||||
return $"AxisAlignedBox(Min={_lo}, Max={_hi})";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -449,8 +449,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("2x2[{0}, {1}, {2}, {3}]",
|
||||
_m11, _m12, _m21, _m22);
|
||||
return $"2x2[{_m11}, {_m12}, {_m21}, {_m22}]";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -633,8 +633,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("3x3[{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}]",
|
||||
_m11, _m12, _m13, _m21, _m22, _m23, _m31, _m32, _m33);
|
||||
return $"3x3[{_m11}, {_m12}, {_m13}, {_m21}, {_m22}, {_m23}, {_m31}, {_m32}, {_m33}]";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -705,8 +705,8 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("4x4[{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}]",
|
||||
_m11, _m12, _m13, _m14, _m21, _m22, _m23, _m24, _m31, _m32, _m33, _m34, _m41, _m42, _m43, _m44);
|
||||
return
|
||||
$"4x4[{_m11}, {_m12}, {_m13}, {_m14}, {_m21}, {_m22}, {_m23}, {_m24}, {_m31}, {_m32}, {_m33}, {_m34}, {_m41}, {_m42}, {_m43}, {_m44}]";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A float representing the shortest distance from the given vector to the plane.</returns>
|
||||
public float GetDistanceToPlane(Vector3 p)
|
||||
{
|
||||
return Vector3.DotProduct(p, this.Normal) - this.Constant;
|
||||
return Vector3.DotProduct(p, Normal) - Constant;
|
||||
}
|
||||
|
||||
public void getEquation(ref Vector3 n, out float d)
|
||||
@@ -253,7 +253,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Plane[n={0}, c={1}]", _normal.ToString(), _const.ToString());
|
||||
return $"Plane[n={_normal.ToString()}, c={_const.ToString()}]";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -648,7 +648,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}, {1}, {2}, {3})", _w, _x, _y, _z);
|
||||
return $"({_w}, {_x}, {_y}, {_z})";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}, {1})", _origin, _direction);
|
||||
return $"({_origin}, {_direction})";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -569,7 +569,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}, {1})", _x, _y);
|
||||
return $"({_x}, {_y})";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -594,7 +594,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}, {1}, {2})", X, Y, Z);
|
||||
return $"({X}, {Y}, {Z})";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -617,7 +617,7 @@ namespace Framework.GameMath
|
||||
/// <returns>A string representation of this object.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("({0}, {1}, {2}, {3})", _x, _y, _z, _w);
|
||||
return $"({_x}, {_y}, {_z}, {_w})";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace Framework.IO
|
||||
private delegate T LoadFromByteRefDelegate(ref byte source);
|
||||
private delegate void CopyMemoryDelegate(ref T dest, ref byte src, int count);
|
||||
|
||||
private readonly static LoadFromByteRefDelegate LoadFromByteRef = BuildLoadFromByteRefMethod();
|
||||
private readonly static CopyMemoryDelegate CopyMemory = BuildCopyMemoryMethod();
|
||||
private static readonly LoadFromByteRefDelegate LoadFromByteRef = BuildLoadFromByteRefMethod();
|
||||
private static readonly CopyMemoryDelegate CopyMemory = BuildCopyMemoryMethod();
|
||||
|
||||
public static readonly int Size = Marshal.SizeOf<T>();
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ abstract class Appender
|
||||
StringBuilder ss = new StringBuilder();
|
||||
|
||||
if (_flags.HasAnyFlag(AppenderFlags.PrefixTimestamp))
|
||||
ss.AppendFormat("{0} ", message.mtime.ToString("MM/dd/yyyy HH:mm:ss"));
|
||||
ss.AppendFormat("{0:MM/dd/yyyy HH:mm:ss} ", message.mtime);
|
||||
|
||||
if (_flags.HasAnyFlag(AppenderFlags.PrefixLogLevel))
|
||||
ss.AppendFormat("{0}: ", message.level);
|
||||
|
||||
@@ -130,12 +130,12 @@ public struct RealmHandle : IEquatable<RealmHandle>
|
||||
}
|
||||
public string GetAddressString()
|
||||
{
|
||||
return string.Format("{0}-{1}-{2}", Region, Site, Realm);
|
||||
return $"{Region}-{Site}-{Realm}";
|
||||
}
|
||||
|
||||
public string GetSubRegionAddress()
|
||||
{
|
||||
return string.Format("{0}-{1}-0", Region, Site);
|
||||
return $"{Region}-{Site}-0";
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace System
|
||||
|
||||
public static byte[] ToByteArray(this string value, char separator)
|
||||
{
|
||||
return Array.ConvertAll(value.Split(separator), s => byte.Parse(s));
|
||||
return Array.ConvertAll(value.Split(separator), byte.Parse);
|
||||
}
|
||||
|
||||
static uint LeftRotate(this uint value, int shiftCount)
|
||||
@@ -144,7 +144,7 @@ namespace System
|
||||
ret = (BigInteger)Convert.ChangeType(value, typeof(BigInteger));
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(string.Format("'{0}' conversion to 'BigInteger' not supported.", typeof(T).Name));
|
||||
throw new NotSupportedException($"'{typeof(T).Name}' conversion to 'BigInteger' not supported.");
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -268,10 +268,7 @@ namespace System
|
||||
string pattern = @"(%\W*\d*[a-zA-Z]*)";
|
||||
|
||||
int count = 0;
|
||||
string result = Regex.Replace(str, pattern, m =>
|
||||
{
|
||||
return string.Concat("{", count++, "}");
|
||||
});
|
||||
string result = Regex.Replace(str, pattern, m => string.Concat("{", count++, "}"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ using System.Diagnostics.Contracts;
|
||||
|
||||
public class RandomHelper
|
||||
{
|
||||
private readonly static Random rand;
|
||||
private static readonly Random rand;
|
||||
|
||||
static RandomHelper()
|
||||
{
|
||||
|
||||
@@ -185,7 +185,7 @@ public static class Time
|
||||
long hours = (time % Day) / Hour;
|
||||
long minute = (time % Hour) / Minute;
|
||||
|
||||
return string.Format("Days: {0} Hours: {1} Minutes: {2}", days, hours, minute);
|
||||
return $"Days: {days} Hours: {hours} Minutes: {minute}";
|
||||
}
|
||||
|
||||
public static void Profile(string description, int iterations, Action func)
|
||||
|
||||
Reference in New Issue
Block a user