Skip to content

Instantly share code, notes, and snippets.

View philcleveland's full-sized avatar

Phil Cleveland philcleveland

View GitHub Profile
public abstract class AggregateRoot : IAggregateRoot
{
private const int DefaultVersion = 0;
private readonly Dictionary<Type, Action<IEvent>> handlers = new Dictionary<Type, Action<IEvent>>();
private List<IEvent> _uncommitedChanges = new List<IEvent>();
public Guid Id { get; protected set; }
public int Version { get; private set; }
@philcleveland
philcleveland / GetEventStoreEventDispatcher.cs
Last active June 8, 2016 23:04
Event dispatcher which receives events from the GetEventStore after they are saved. It takes the saved events and publishes them to the passed in Event Bus. This ensures that events are not published until they are saved in the GetEventStore. Big thanks to Andrii for all the reviews and coding help to get this thing working.
public class GetEventStoreEventDispatcher
{
private const int RECONNECT_TIMEOUT_MILLISEC = 5000;
private const int THREAD_KILL_TIMEOUT_MILLISEC = 5000;
private const int READ_PAGE_SIZE = 500;
private const int LIVE_QUEUE_SIZE_LIMIT = 10000;
private readonly IEventBus _eventBus;
private readonly EventStoreConnection _store;
using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using EventStore.ClientAPI;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Hosting;
using Owin;
namespace EventStoreSignalR
@philcleveland
philcleveland / GetEventStoreEventDispatcher.cs
Last active December 16, 2015 05:19
GetEventStore Event Dispatcher EventStore.ClientAPI compatable v1.1.0
//Special thanks to Andrii Nakryiko and James Nugent
//for their help with this code.
namespace Infrastructure.EventStorage
{
using System;
using System.Collections.Concurrent;
using System.Net;
using System.Text;
using System.Threading;
using EventStore.ClientAPI;
@philcleveland
philcleveland / gist:7159081
Created October 25, 2013 18:01
Trying to pass variable from TFS to WiX
I have a Variable defined in my TFS Build template
Name:TFSGenProductVersion
Type:String
Scope:Sequence
Default:"3.1.2"
I added this to the wixproj
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>Debug;MyProductVersion=0.0.0.1</DefineConstants>
@philcleveland
philcleveland / SearchViewModel.cs
Created November 5, 2013 19:40
SearchViewModel with ReactiveUI
using ReactiveUI;
using System.Threading.Tasks;
using System.Windows.Input;
using TwitterFeedAPI;
namespace FeedManagement.WPF.Search
{
public class SearchViewModel : ReactiveObject, ISearchViewModel
{
public IScreen HostScreen { get; protected set; }
@philcleveland
philcleveland / rx_OAPHprop.snippet
Last active June 28, 2016 23:05
RxUI VS snippets
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Rx ObservableAsPropertyHelper</Title>
<Shortcut>rxOAPH</Shortcut>
<Description>Code snippet for a ReactiveUI ObservableAsPropertyHelper</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
@philcleveland
philcleveland / App.cs
Last active December 28, 2015 03:29
RxUI Search example
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
//ghetto bootstrap - IS THIS OK?
var searchView = new SearchView();
searchView.ViewModel = new SearchViewModel();
searchView.DataContext = searchView.ViewModel;
@philcleveland
philcleveland / StreamTrackedContentViewModel.cs
Created December 2, 2013 00:43
PlayingWithReactiveUIandTwitter
public class StreamTrackedContentViewModel : ReactiveObject
{
public StreamTrackedContentViewModel(Twitter twitterApi)
{
Tweets = new ReactiveList<Tweet>();
TweetViewModels = Tweets.CreateDerivedCollection(tweet => new TweetTileViewModel(tweet.CreatedAt,
tweet.UserPic,
tweet.UserName,
tweet.ScreenName,
tweet.Text));
@philcleveland
philcleveland / ABetterKeyPressCapture.cs
Last active January 17, 2020 01:06
Shows how to use Rx to capture keypress events. I use it for fastforward and reverse in the media sense. ABetterKeyPressCapture.cs was written by Chris Harris @cwharris. I appreciate his answer on StackOverflow.
using System;
using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows.Forms;
namespace RxStuff
{
class Program
{