Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 4109043

Browse files
author
Mat McLoughlin
committed
starting
1 parent 8ed56b2 commit 4109043

6 files changed

Lines changed: 303 additions & 0 deletions

File tree

SqlStreamStore.HAL.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.0.0
5+
MinimumVisualStudioVersion = 10.0.0.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlStreamStore.HAL", "SqlStreamStore.HAL/SqlStreamStore.HAL.csproj", "{A8770217-10C4-4388-8AE3-24BAF873AB9C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A8770217-10C4-4388-8AE3-24BAF873AB9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A8770217-10C4-4388-8AE3-24BAF873AB9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A8770217-10C4-4388-8AE3-24BAF873AB9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A8770217-10C4-4388-8AE3-24BAF873AB9C}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

SqlStreamStore.HAL/Program.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using Microsoft.Owin.Builder;
3+
using Microsoft.Owin.Hosting;
4+
using Owin;
5+
using SqlStreamStore.Streams;
6+
using MidFunc = System.Func<
7+
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>,
8+
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>>;
9+
10+
namespace SqlStreamStore.HAL
11+
{
12+
internal class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
var streamStore = new InMemoryStreamStore();
17+
var messages = SeedData.Get(1000);
18+
19+
streamStore.AppendToStream("SomeStream", ExpectedVersion.Any, messages);
20+
21+
var settings = new HALSettings {Url = "Stream"};
22+
var baseUrl = "http://localhost:8080";
23+
24+
using (WebApp.Start(baseUrl, app => app.Use(HALMiddleware.Handle(settings))))
25+
{
26+
Console.WriteLine("Press Enter to quit.");
27+
Console.ReadKey();
28+
}
29+
}
30+
}
31+
32+
public class FooMessage
33+
{
34+
}
35+
36+
internal static class HALMiddleware
37+
{
38+
public static MidFunc Handle(HALSettings settings)
39+
{
40+
return next =>
41+
{
42+
var appBuilder = new AppBuilder();
43+
appBuilder.Run(context =>
44+
{
45+
context.Response.ContentType = "text/plain";
46+
47+
string output = string.Format(
48+
"I'm running on {0} nFrom assembly {1}",
49+
Environment.OSVersion,
50+
System.Reflection.Assembly.GetEntryAssembly().FullName
51+
);
52+
53+
return context.Response.WriteAsync(output);
54+
});
55+
return appBuilder.Build();
56+
};
57+
}
58+
}
59+
60+
internal class HALSettings
61+
{
62+
public string Url { get; set; }
63+
}
64+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
9+
[assembly: AssemblyTitle("SqlStreamStore.HAL")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("SqlStreamStore.HAL")]
14+
[assembly: AssemblyCopyright("Copyright © 2016")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
18+
// Setting ComVisible to false makes the types in this assembly not visible
19+
// to COM components. If you need to access a type in this assembly from
20+
// COM, set the ComVisible attribute to true on that type.
21+
22+
[assembly: ComVisible(false)]
23+
24+
// The following GUID is for the ID of the typelib if this project is exposed to COM
25+
26+
[assembly: Guid("A8770217-10C4-4388-8AE3-24BAF873AB9C")]
27+
28+
// Version information for an assembly consists of the following four values:
29+
//
30+
// Major Version
31+
// Minor Version
32+
// Build Number
33+
// Revision
34+
//
35+
// You can specify all the values or you can default the Build and Revision Numbers
36+
// by using the '*' as shown below:
37+
// [assembly: AssemblyVersion("1.0.*")]
38+
39+
[assembly: AssemblyVersion("1.0.0.0")]
40+
[assembly: AssemblyFileVersion("1.0.0.0")]
41+

SqlStreamStore.HAL/SeedData.cs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using SqlStreamStore.Streams;
4+
using StreamStoreStore.Json;
5+
6+
namespace SqlStreamStore.HAL
7+
{
8+
public static class SeedData
9+
{
10+
static readonly Dictionary<int, Func<object>> Factory = new Dictionary<int, Func<object>>
11+
{
12+
{0, Fizz.Get},
13+
{1, FizzBuzz.Get},
14+
{2, Buzz.Get}
15+
};
16+
17+
public static IEnumerable<NewStreamMessage> Get(int count)
18+
{
19+
var rand = new Random();
20+
21+
for (var i = 0; i < count; i++)
22+
{
23+
var random = rand.Next(0, 3);
24+
var message = Factory[random]();
25+
26+
yield return new NewStreamMessage(
27+
Guid.NewGuid(),
28+
message.GetType().FullName.ToString(),
29+
SimpleJson.SerializeObject(new FooMessage())
30+
);
31+
}
32+
}
33+
}
34+
35+
public class Fizz
36+
{
37+
public int Lorem { get; set; }
38+
39+
public int Ipsum { get; set; }
40+
41+
public int Dolor { get; set; }
42+
43+
public static Fizz Get()
44+
{
45+
var rand = new Random();
46+
return new Fizz
47+
{
48+
Lorem = rand.Next(0, 10000000),
49+
Ipsum = rand.Next(0, 10000),
50+
Dolor = rand.Next(0, 100)
51+
};
52+
}
53+
}
54+
55+
public class Buzz
56+
{
57+
public int Consectetur { get; set; }
58+
59+
public int Adipiscing { get; set; }
60+
61+
public int Aliquam { get; set; }
62+
63+
public static Buzz Get()
64+
{
65+
var rand = new Random();
66+
return new Buzz
67+
{
68+
Consectetur = rand.Next(0, 10000000),
69+
Adipiscing = rand.Next(0, 10000),
70+
Aliquam = rand.Next(0, 100)
71+
};
72+
}
73+
}
74+
75+
public class FizzBuzz
76+
{
77+
public int Hendrerit { get; set; }
78+
79+
public int Efficitur { get; set; }
80+
81+
public int Libero { get; set; }
82+
83+
public static FizzBuzz Get()
84+
{
85+
var rand = new Random();
86+
return new FizzBuzz
87+
{
88+
Hendrerit = rand.Next(0, 10000000),
89+
Efficitur = rand.Next(0, 10000),
90+
Libero = rand.Next(0, 100)
91+
};
92+
}
93+
}
94+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{A8770217-10C4-4388-8AE3-24BAF873AB9C}</ProjectGuid>
8+
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>SqlStreamStore.HAL</RootNamespace>
12+
<AssemblyName>SqlStreamStore.HAL</AssemblyName>
13+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
37+
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
40+
<HintPath>..\packages\Microsoft.Owin.Host.HttpListener.3.0.1\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Microsoft.Owin.Hosting, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
43+
<HintPath>..\packages\Microsoft.Owin.Hosting.3.0.1\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5">
46+
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
47+
</Reference>
48+
<Reference Include="SqlStreamStore, Version=0.4.3.0, Culture=neutral, PublicKeyToken=null">
49+
<HintPath>..\packages\SqlStreamStore.0.4.3\lib\Portable-Net45+Win8+WP8+WPA81\SqlStreamStore.dll</HintPath>
50+
</Reference>
51+
<Reference Include="System" />
52+
<Reference Include="System.Core" />
53+
<Reference Include="System.Xml.Linq" />
54+
<Reference Include="System.Data.DataSetExtensions" />
55+
<Reference Include="System.Data" />
56+
<Reference Include="System.Xml" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<Compile Include="Program.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
<Compile Include="SeedData.cs" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<Content Include="packages.config" />
65+
</ItemGroup>
66+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
67+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
68+
Other similar extension points exist, see Microsoft.Common.targets.
69+
<Target Name="BeforeBuild">
70+
</Target>
71+
<Target Name="AfterBuild">
72+
</Target>
73+
-->
74+
</Project>

SqlStreamStore.HAL/packages.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
4+
<package id="Microsoft.Owin.Host.HttpListener" version="3.0.1" targetFramework="net45" />
5+
<package id="Microsoft.Owin.Hosting" version="3.0.1" targetFramework="net45" />
6+
<package id="Owin" version="1.0" targetFramework="net45" />
7+
<package id="SqlStreamStore" version="0.4.3" targetFramework="net45" />
8+
</packages>

0 commit comments

Comments
 (0)