This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace YourProject.YourForlder | |
{ | |
using System; | |
using YourProject.Abstractions.Interfaces; | |
public static class MessageParser | |
{ | |
public static bool TryParse(IReader reader, out int messageId, out int dataLength, out byte[] data) | |
{ | |
messageId = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PartsManager<TP, T> | |
where TP : AbstractPart<T> | |
{ | |
private static Dictionary<TP, MethodInfo> PartMapper { get; } | |
static PartsManager() | |
{ | |
var ass = typeof(TP).Assembly; | |
var types = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Entry Point of the App | |
/// </summary> | |
public partial class App | |
{ | |
private CancellationTokenSource _mainTokenSource; | |
private TaskScheduler _mainScheduler; | |
public TaskFactory MainFactory() | |
=> new TaskFactory( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Simple console logger, this is basically a text formatter | |
/// </summary> | |
public class ConsoleLogger | |
{ | |
private static Dictionary<LogType, ConsoleColor> ColorWrapper { get; } | |
static ConsoleLogger() | |
{ | |
ColorWrapper = new Dictionary<LogType, ConsoleColor>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LogMessage | |
{ | |
public LogType LogType { get; } | |
public string Message { get; } | |
public string Source { get; } | |
public DateTime Timestamp { get; } | |
public Exception Exception { get; } | |
private LogMessage(LogType logType, string message, string sourceName, Exception exception = null) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoggerFactory | |
{ | |
public ILogger Logger { get; } | |
public AsyncCollection<LogMessage> MessageCollection { get; } | |
private ILogWriter LogWriter { get; } | |
private CancellationTokenSource MainTokenSource { get; } | |
private TaskFactory DispatcherFactory() | |
=> new TaskFactory( | |
MainTokenSource.Token, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GNU GENERAL PUBLIC LICENSE | |
Version 3, 29 June 2007 | |
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | |
Everyone is permitted to copy and distribute verbatim copies | |
of this license document, but changing it is not allowed. | |
Preamble | |
The GNU General Public License is a free, copyleft license for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public delegate TObj InitializerDlg(); | |
public static Delegate GetDynamicDlg() | |
{ | |
var ctor = typeof(TObj).GetTypeInfo() | |
.DeclaredConstructors | |
.First( | |
c => c.GetParameters().Length < 1); | |
var method = new DynamicMethod( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Use this strategy to output logs to your console. | |
/// </summary> | |
public class ConsoleOutputStrategy : LoggingStrategy | |
{ | |
private readonly Dictionary<LogLevel, ConsoleColor> _colorWrapper = new Dictionary<LogLevel, ConsoleColor>() | |
{ | |
{LogLevel.Trace, ConsoleColor.DarkGreen }, | |
{LogLevel.Debug, ConsoleColor.Green }, | |
{LogLevel.Info, ConsoleColor.Blue }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomVarInt16BinaryStorage : IBinaryStorage<CustomVar<short>> | |
{ | |
public Func<IReader, CustomVar<short>> ReadValue => reader => | |
{ | |
var result = 0; | |
for (var offset = 0; offset < 16; offset += 7) | |
{ | |
var readByte = reader.ReadValue<sbyte>(); | |
var hasNext = (readByte & 128) == 128; |
OlderNewer