Skip to content

Instantly share code, notes, and snippets.

View RupertAvery's full-sized avatar

David Khristepher Santos RupertAvery

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace MappingUtil.Common
{
/// <summary>
/// Implements a MappingProvider
@RupertAvery
RupertAvery / Job.cs
Last active February 26, 2024 08:32
A wrapper class using Channels to asynchonously process a queue that can be added to at any time
public class Job
{
private static int lastId;
public int Id { get; private set; }
public int Duration { get; private set; }
public Job(int value)
{
Id = lastId + 1;
@RupertAvery
RupertAvery / AudioDevice.cs
Last active September 8, 2022 20:56
AudioDeviceManager
namespace MyAudio
{
public class AudioDevice
{
public string Name { get; set; }
public string Direction { get; set; }
public bool IsEnabled { get; set; }
public string DeviceId { get; set; }
}
}
@RupertAvery
RupertAvery / BaseNotifyModel.cs
Last active September 4, 2022 02:45
WPF ListView Binding
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace WPFSample
{
public class BaseNotifyModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
@RupertAvery
RupertAvery / FastMethodInfo.cs
Last active April 13, 2022 01:53
FastMethodInfo with Generics
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
namespace Bite.Runtime.Functions.ForeignInterface
{
public class FastMethodInfo
{
private delegate object ReturnValueDelegate(object instance, object[] arguments);
@RupertAvery
RupertAvery / Program.cs
Last active December 11, 2021 00:42
Trimmed INSERT Parser for ANTLR
using Antlr4.Runtime;
using Antlr4.Runtime.Tree;
using System;
namespace TSQLParser
{
class Program
{
static void Main(string[] args)
{
@RupertAvery
RupertAvery / CaseChangingCharStream.cs
Last active December 11, 2021 01:05
ANTLR4 TSQLParser Sample Project
using Antlr4.Runtime;
using Antlr4.Runtime.Misc;
namespace TSQLParser
{
/// <summary>
/// This class supports case-insensitive lexing by wrapping an existing
/// <see cref="ICharStream"/> and forcing the lexer to see either upper or
/// lowercase characters. Grammar literals should then be either upper or
/// lower case such as 'BEGIN' or 'begin'. The text of the character
@RupertAvery
RupertAvery / Program.cs
Created October 30, 2021 02:20
Text Adventure
using System;
using System.Collections.Generic;
using System.Linq;
namespace TextAdventure
{
class Program
{
static void Main(string[] args)
{
@RupertAvery
RupertAvery / ConditionExpression.cs
Last active September 28, 2021 09:07
Rule-based filtered Select
public class ConditionExpression<TFilter>
{
public Func<TFilter, bool> Condition { get; }
public Expression Expression { get; }
public ConditionExpression(Func<TFilter, bool> condition, Expression expression)
{
Condition = condition;
Expression = expression;
}
namespace WINKCrossViewX
{
public class AppSettings
{
public string Forges { get; set; }
public string APIUsername { get; set; }
public string APIPassword { get; set; }
public string RefreshInterval { get; set; }
}