Skip to content

Instantly share code, notes, and snippets.

View INTERNALINTERFERENCE's full-sized avatar
:octocat:
Working from home

whowantswhat INTERNALINTERFERENCE

:octocat:
Working from home
View GitHub Profile
public sealed class MessageErrorsManager
{
readonly ConcurrentDictionary<string, MessageErrorObject> errors = new();
public void AddError(MessageErrorObject? error)
{
var correlationId = CorrelationIdHelper.Get();
try
{
Log.WriteDebug($"{nameof(MessageErrorsManager)}: started.", correlationId);
if(error is null)
using Confluent.Kafka;
// producer
Task.Run(() =>
{
Console.WriteLine("producer started");
var conf = new ProducerConfig { BootstrapServers = "localhost:29092" };
Action<DeliveryReport<Null, string>> handler = r =>
Console.WriteLine(!r.Error.IsError
public class VerbalizedEvent
{
private readonly EventData _eventData;
public VerbalizedEvent(MqttDelivery delivery)
{
Delivery = delivery;
if ( delivery.TryGetPayload<PayloadWithEventData>(out var payload))
{
using UISchema.Attributes;
using System;
using System.Collections.Generic;
using System.Xml;
namespace UISchema.Builder;
public class UISchemaBuilder
{
private readonly string _groupName;
public static class ExtendedGCD
{
#region General
/// <summary>
/// Остаток от деления, как в Питоне
/// </summary>
/// <param name="a"></param>
/// <param name="p"></param>
/// <returns></returns>
@INTERNALINTERFERENCE
INTERNALINTERFERENCE / .cs
Created July 14, 2023 11:39
FixedSizeQueue
public class FixedSizeQueue<T>
: IReadOnlyCollection<T>
{
private readonly T[] _items;
private int _tail;
public FixedSizeQueue(int capacity)
{
if (capacity <= 0)
[ApiCommands]
abstract public class Commands
{
[ApiArgument( typeof( SubjectsListArguments ), isOptional: true )]
[ApiReturn( typeof( SubjectsListResponse ) )]
[Title]
[Description]
public const string SubjectsList = "subjects_list";
}
static public class CustomTypeMapper
{
static private readonly Dictionary<Type, Func<OpenApiSchema>> _typeToOpenApiSchema = new()
{
[typeof(bool)] = () => new OpenApiSchema { Type = "boolean" },
[typeof(byte)] = () => new OpenApiSchema { Type = "string", Format = "byte" },
[typeof(int)] = () => new OpenApiSchema { Type = "integer", Format = "int32" },
[typeof(uint)] = () => new OpenApiSchema { Type = "integer", Format = "int32" },
[typeof(long)] = () => new OpenApiSchema { Type = "integer", Format = "int64" },
[typeof(ulong)] = () => new OpenApiSchema { Type = "integer", Format = "int64" },
internal class OpenApiGenerator
{
public string GenerateYaml(
Type apiType,
CultureInfo culture)
{
var metadata = ApiMetadata.FromType(apiType);
if (metadata == null)
throw new Exception("The given type is not API");
[ApiEndpoint( Name, SignatureBase )]
[Title]
[Description]
abstract public class ReportsAPI
{
public const string Name = "reports";
public const string SignatureBase = "/system/report";
static public readonly EndpointSignature Signature =