Introduce CustomEventHandler for more flexible invocation
This commit is contained in:
@ -22,5 +22,30 @@ namespace RageCoop.Core
|
||||
public static T JsonDeserialize<T>(string text) => (T)JsonDeserialize(text, typeof(T));
|
||||
|
||||
public static string JsonSerialize(object obj) => JsonConvert.SerializeObject(obj, JsonSettings);
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to <see cref="BufferReader.ThreadLocal"/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static unsafe BufferReader GetReader(byte* data=null,int cbData=0)
|
||||
{
|
||||
var reader = BufferReader.ThreadLocal.Value;
|
||||
reader.Initialise(data,cbData);
|
||||
return reader;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to <see cref="BufferWriter.ThreadLocal"/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static BufferWriter GetWriter(bool reset=true) {
|
||||
var writer=BufferWriter.ThreadLocal.Value;
|
||||
if (reset)
|
||||
{
|
||||
writer.Reset();
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user