Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dbones's full-sized avatar
☄️
Coding the dotNEXT

Dave R. dbones

☄️
Coding the dotNEXT
View GitHub Profile
@dbones
dbones / ObjectComparer.cs
Created August 14, 2011 19:00
Compares 2 objects to see if they are the same or have the same values, tries to handle circluar references (not fully tested, written in a rush)
/// <summary>
/// Compares 2 objects to see if they are the same or have the same values
/// </summary>
public class ObjectComparer
{
private readonly IList<object> _compared;
private readonly IDictionary<Type,IList<string>> _skipList;
public ObjectComparer()
{
@dbones
dbones / HiloIdGenerator.cs
Created May 23, 2012 05:26
Basic Hilo Id Generator class,
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace TestEtl.Infrastructure
{
public interface IIdGenerator
@dbones
dbones / gist:4758935
Created February 12, 2013 00:23
List<T> vs HashSet<T> this is hack out code, it can be done better, but allows you to see how fast the collection will work with an object.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
namespace CollectionTest
{
class Program
{
@dbones
dbones / InternalContainer.cs
Created July 15, 2013 19:42
simple internal IoC container, based on the ninject one. only handles singletons.
public interface IContainer : IDisposable
{
void Add(Type contract, Type service);
object Resolve(Type contract);
}
/// <summary>
/// this contaier is a simple container which handles all contracts as singletons
/// </summary>
@dbones
dbones / nav
Created September 5, 2013 23:24
wondering how you may implement a menu (navigation)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestMenuIdea
{
class Program
{
static void Main(string[] args)
@dbones
dbones / ConfigSample.cs
Last active December 23, 2015 02:39
This shows a simple pattern for implementing Configurations and setting them. The code shows a sample logger which is set-up via the code, you could easily extend it to configure by XML
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@dbones
dbones / config-logging.cs
Last active December 22, 2019 23:53
Building on my previous Gist, <https://gist.github.com/dbones/6568314>, this looks into a process worker to queue the tasks and run on them on another thread (you could easily use the Thread Queue instead)this offers a simple interface around the worker to allow for an easy swap at any time
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace TestConfuring
{
@dbones
dbones / gist:7298086
Last active December 27, 2015 08:39
FluentRegex - create a regex text via a fluent interface
using System;
using System.Collections.Generic;
using System.Linq;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
namespace FluentRegex
{
@dbones
dbones / StreamCopy.cs
Created March 1, 2014 22:44
StreamCopy - Copy the contents from one stream to another, it also implements the INPC to allow updating of the UI of number of bytes copied and also the bytes per second (minimal testing applied)
public class StreamCopy : INotifyPropertyChanged
{
private readonly Stream _source;
private readonly Stream _destination;
private readonly int _bufferSize;
private readonly TransferStatus _transferStatus;
private long _numberOfBytesCopied;
internal StreamCopy(Stream source, Stream destination, int bufferSize = 1024)
{
@dbones
dbones / gist:9569663
Created March 15, 2014 16:07
classes which I use for testing ( ArmChair which is hopefully comming soon )
/// <summary>
/// base for all domain object which use this Uow
/// </summary>
public abstract class EntityRoot
{
public virtual int Id { get; protected set; }
}
public class Book : EntityRoot