Rework on SendNativeCall
This commit is contained in:
@ -16,7 +16,7 @@ namespace RageCoop.Core
|
||||
switch (obj)
|
||||
{
|
||||
case byte _:
|
||||
return (0x01, BitConverter.GetBytes((byte)obj));
|
||||
return (0x01, new byte[] { (byte)obj });
|
||||
case short _:
|
||||
return (0x02, BitConverter.GetBytes((short)obj));
|
||||
case ushort _:
|
||||
@ -120,5 +120,87 @@ namespace RageCoop.Core
|
||||
{
|
||||
return (flagToCheck & flag)!=0;
|
||||
}
|
||||
public static Type GetActualType(this TypeCode code)
|
||||
{
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case TypeCode.Boolean:
|
||||
return typeof(bool);
|
||||
|
||||
case TypeCode.Byte:
|
||||
return typeof(byte);
|
||||
|
||||
case TypeCode.Char:
|
||||
return typeof(char);
|
||||
|
||||
case TypeCode.DateTime:
|
||||
return typeof(DateTime);
|
||||
|
||||
case TypeCode.DBNull:
|
||||
return typeof(DBNull);
|
||||
|
||||
case TypeCode.Decimal:
|
||||
return typeof(decimal);
|
||||
|
||||
case TypeCode.Double:
|
||||
return typeof(double);
|
||||
|
||||
case TypeCode.Empty:
|
||||
return null;
|
||||
|
||||
case TypeCode.Int16:
|
||||
return typeof(short);
|
||||
|
||||
case TypeCode.Int32:
|
||||
return typeof(int);
|
||||
|
||||
case TypeCode.Int64:
|
||||
return typeof(long);
|
||||
|
||||
case TypeCode.Object:
|
||||
return typeof(object);
|
||||
|
||||
case TypeCode.SByte:
|
||||
return typeof(sbyte);
|
||||
|
||||
case TypeCode.Single:
|
||||
return typeof(Single);
|
||||
|
||||
case TypeCode.String:
|
||||
return typeof(string);
|
||||
|
||||
case TypeCode.UInt16:
|
||||
return typeof(UInt16);
|
||||
|
||||
case TypeCode.UInt32:
|
||||
return typeof(UInt32);
|
||||
|
||||
case TypeCode.UInt64:
|
||||
return typeof(UInt64);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public static string DumpWithType(this IEnumerable<object> objects)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach(var obj in objects)
|
||||
{
|
||||
sb.Append(obj.GetType()+":"+obj.ToString()+"\n");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public static string Dump<T>(this IEnumerable<T> objects)
|
||||
{
|
||||
return "{"+string.Join(",",objects)+"}";
|
||||
}
|
||||
public static void ForEach<T>(this IEnumerable<T> objects,Action<T> action)
|
||||
{
|
||||
foreach(var obj in objects)
|
||||
{
|
||||
action(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user