Code cleanup.

This commit is contained in:
2018-06-22 08:08:38 +01:00
parent 82f474c7e3
commit 88da8fc019
581 changed files with 22423 additions and 20839 deletions

View File

@@ -239,7 +239,7 @@ namespace DiscImageChef
public static short ToInt16(byte[] value, int startIndex)
{
return !IsLittleEndian
? BitConverter.ToInt16(value, startIndex)
? BitConverter.ToInt16(value, startIndex)
: BitConverter.ToInt16(value.Reverse().ToArray(), value.Length - sizeof(short) - startIndex);
}
@@ -261,7 +261,7 @@ namespace DiscImageChef
public static int ToInt32(byte[] value, int startIndex)
{
return !IsLittleEndian
? BitConverter.ToInt32(value, startIndex)
? BitConverter.ToInt32(value, startIndex)
: BitConverter.ToInt32(value.Reverse().ToArray(), value.Length - sizeof(int) - startIndex);
}
@@ -283,7 +283,7 @@ namespace DiscImageChef
public static long ToInt64(byte[] value, int startIndex)
{
return !IsLittleEndian
? BitConverter.ToInt64(value, startIndex)
? BitConverter.ToInt64(value, startIndex)
: BitConverter.ToInt64(value.Reverse().ToArray(), value.Length - sizeof(long) - startIndex);
}
@@ -306,7 +306,7 @@ namespace DiscImageChef
public static float ToSingle(byte[] value, int startIndex)
{
return !IsLittleEndian
? BitConverter.ToSingle(value, startIndex)
? BitConverter.ToSingle(value, startIndex)
: BitConverter.ToSingle(value.Reverse().ToArray(), value.Length - sizeof(float) - startIndex);
}
@@ -343,7 +343,7 @@ namespace DiscImageChef
public static string ToString(byte[] value, int startIndex)
{
return !IsLittleEndian
? BitConverter.ToString(value, startIndex)
? BitConverter.ToString(value, startIndex)
: BitConverter.ToString(value.Reverse().ToArray(), startIndex);
}
@@ -370,7 +370,7 @@ namespace DiscImageChef
public static string ToString(byte[] value, int startIndex, int length)
{
return !IsLittleEndian
? BitConverter.ToString(value, startIndex, length)
? BitConverter.ToString(value, startIndex, length)
: BitConverter.ToString(value.Reverse().ToArray(), startIndex, length);
}
@@ -389,7 +389,7 @@ namespace DiscImageChef
public static ushort ToUInt16(byte[] value, int startIndex)
{
return !IsLittleEndian
? BitConverter.ToUInt16(value, startIndex)
? BitConverter.ToUInt16(value, startIndex)
: BitConverter.ToUInt16(value.Reverse().ToArray(), value.Length - sizeof(ushort) - startIndex);
}
@@ -411,7 +411,7 @@ namespace DiscImageChef
public static uint ToUInt32(byte[] value, int startIndex)
{
return !IsLittleEndian
? BitConverter.ToUInt32(value, startIndex)
? BitConverter.ToUInt32(value, startIndex)
: BitConverter.ToUInt32(value.Reverse().ToArray(), value.Length - sizeof(uint) - startIndex);
}
@@ -433,16 +433,19 @@ namespace DiscImageChef
public static ulong ToUInt64(byte[] value, int startIndex)
{
return !IsLittleEndian
? BitConverter.ToUInt64(value, startIndex)
? BitConverter.ToUInt64(value, startIndex)
: BitConverter.ToUInt64(value.Reverse().ToArray(), value.Length - sizeof(ulong) - startIndex);
}
public static Guid ToGuid(byte[] value, int startIndex)
{
return new Guid(ToUInt32(value, 0 + startIndex), ToUInt16(value, 4 + startIndex),
ToUInt16(value, 6 + startIndex), value[8 + startIndex + 0], value[8 + startIndex + 1],
value[8 + startIndex + 2], value[8 + startIndex + 3], value[8 + startIndex + 5],
value[8 + startIndex + 5], value[8 + startIndex + 6], value[8 + startIndex + 7]);
ToUInt16(value, 6 + startIndex), value[8 + startIndex + 0],
value[8 + startIndex + 1],
value[8 + startIndex + 2], value[8 + startIndex + 3],
value[8 + startIndex + 5],
value[8 + startIndex + 5], value[8 + startIndex + 6],
value[8 + startIndex + 7]);
}
}
}