Skip to content

Commit 09be825

Browse files
committed
Ugh
1 parent 959c123 commit 09be825

39 files changed

+42776
-0
lines changed

FunWithSignalRAndUnity.sln

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.24720.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunWithSignalRAndUnity", "FunWithSignalRAndUnity\FunWithSignalRAndUnity.csproj", "{AB3D1E86-C8BA-4E63-8A4D-3FF692935E22}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunWithSignalRAndUnity.Tests", "FunWithSignalRAndUnity.Tests\FunWithSignalRAndUnity.Tests.csproj", "{517DAD97-7338-4380-B9C8-D019A53D65D0}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{AB3D1E86-C8BA-4E63-8A4D-3FF692935E22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{AB3D1E86-C8BA-4E63-8A4D-3FF692935E22}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{AB3D1E86-C8BA-4E63-8A4D-3FF692935E22}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{AB3D1E86-C8BA-4E63-8A4D-3FF692935E22}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{517DAD97-7338-4380-B9C8-D019A53D65D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{517DAD97-7338-4380-B9C8-D019A53D65D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{517DAD97-7338-4380-B9C8-D019A53D65D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{517DAD97-7338-4380-B9C8-D019A53D65D0}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
using System.Web.Routing;
7+
8+
namespace FunWithSignalRAndUnity
9+
{
10+
public class RouteConfig
11+
{
12+
public static void RegisterRoutes(RouteCollection routes)
13+
{
14+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15+
16+
routes.MapRoute(
17+
name: "Default",
18+
url: "{controller}/{action}/{id}",
19+
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20+
);
21+
}
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using FunWithSignalRAndUnity.Common;
2+
using FunWithSignalRAndUnity.Hubs;
3+
using Microsoft.AspNet.SignalR.Hubs;
4+
using Microsoft.Practices.Unity;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Web;
9+
10+
namespace FunWithSignalRAndUnity
11+
{
12+
public class UnityConfiguration
13+
{
14+
#region Unity Container
15+
private static Lazy<IUnityContainer> container = new Lazy<IUnityContainer>(() =>
16+
{
17+
var container = new UnityContainer();
18+
RegisterTypes(container);
19+
return container;
20+
});
21+
22+
public static IUnityContainer GetConfiguredContainer()
23+
{
24+
return container.Value;
25+
}
26+
#endregion
27+
28+
public static void RegisterTypes(IUnityContainer container)
29+
{
30+
container.RegisterType<ProductsHub, ProductsHub>(new ContainerControlledLifetimeManager());
31+
container.RegisterType<IHubActivator, UnityHubActivator>(new ContainerControlledLifetimeManager());
32+
container.RegisterType<IProductRepository, ProductRepository>();
33+
}
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using FunWithSignalRAndUnity.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Web;
6+
7+
namespace FunWithSignalRAndUnity.Common
8+
{
9+
public interface IProductRepository
10+
{
11+
void Add(Product product);
12+
Product GetById(int id);
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using FunWithSignalRAndUnity.Models;
6+
7+
namespace FunWithSignalRAndUnity.Common
8+
{
9+
public class ProductRepository : IProductRepository
10+
{
11+
private static readonly List<Product> Products;
12+
13+
static ProductRepository()
14+
{
15+
Products = new List<Product>
16+
{
17+
new Product { Id = 1, Description = "Product 1" },
18+
new Product { Id = 2, Description = "Product 2" },
19+
new Product { Id = 3, Description = "Product 3" }
20+
};
21+
}
22+
23+
public void Add(Product product)
24+
{
25+
Products.Add(product);
26+
}
27+
28+
public Product GetById(int id)
29+
{
30+
return Products.Where(x => x.Id == id).SingleOrDefault();
31+
}
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Microsoft.AspNet.SignalR.Hubs;
2+
using Microsoft.Practices.Unity;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Web;
7+
8+
namespace FunWithSignalRAndUnity.Common
9+
{
10+
public class UnityHubActivator : IHubActivator
11+
{
12+
private readonly IUnityContainer _container;
13+
14+
public UnityHubActivator(IUnityContainer container)
15+
{
16+
_container = container;
17+
}
18+
19+
public IHub Create(HubDescriptor descriptor)
20+
{
21+
if (descriptor == null)
22+
{
23+
throw new ArgumentNullException("descriptor");
24+
}
25+
26+
if (descriptor.HubType == null)
27+
{
28+
return null;
29+
}
30+
31+
object hub = _container.Resolve(descriptor.HubType) ?? Activator.CreateInstance(descriptor.HubType);
32+
return hub as IHub;
33+
}
34+
}
35+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
body {
2+
padding-top: 50px;
3+
padding-bottom: 20px;
4+
}
5+
6+
/* Set padding to keep content from hitting the edges */
7+
.body-content {
8+
padding-left: 15px;
9+
padding-right: 15px;
10+
}
11+
12+
/* Set width on the form input elements since they're 100% wide by default */
13+
input,
14+
select,
15+
textarea {
16+
max-width: 280px;
17+
}
18+

0 commit comments

Comments
 (0)