Skip to content

Commit 4707024

Browse files
committed
worked on silverlight frontend
1 parent 988ab61 commit 4707024

File tree

183 files changed

+713
-26203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+713
-26203
lines changed

source/ConOverConf.ConsoleHost/ConOverConf.ConsoleHost.csproj

+18
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,26 @@
3535
<WarningLevel>4</WarningLevel>
3636
</PropertyGroup>
3737
<ItemGroup>
38+
<Reference Include="Antlr3.Runtime, Version=3.1.3.42154, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7, processorArchitecture=MSIL" />
39+
<Reference Include="Castle.Core">
40+
<HintPath>..\packages\Castle.Core.2.5.1\lib\NET35\Castle.Core.dll</HintPath>
41+
</Reference>
42+
<Reference Include="FluentNHibernate, Version=1.1.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL" />
43+
<Reference Include="Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL" />
3844
<Reference Include="Microsoft.Practices.Unity">
3945
<HintPath>..\packages\Unity.2.0\lib\20\Microsoft.Practices.Unity.dll</HintPath>
4046
</Reference>
47+
<Reference Include="NHibernate, Version=3.0.0.2001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
48+
<SpecificVersion>False</SpecificVersion>
49+
<HintPath>..\packages\NHibernate.Core.3.0.0.2001\lib\NHibernate.dll</HintPath>
50+
</Reference>
51+
<Reference Include="NHibernate.ByteCode.Castle">
52+
<HintPath>..\packages\NHibernate.Core.3.0.0.2001\lib\NHibernate.ByteCode.Castle.dll</HintPath>
53+
</Reference>
54+
<Reference Include="Remotion.Data.Linq, Version=1.13.41.2, Culture=neutral, PublicKeyToken=cab60358ab4081ea, processorArchitecture=MSIL">
55+
<SpecificVersion>False</SpecificVersion>
56+
<HintPath>..\packages\NHibernate.Core.3.0.0.2001\lib\Remotion.Data.Linq.dll</HintPath>
57+
</Reference>
4158
<Reference Include="StructureMap">
4259
<HintPath>..\packages\structuremap.2.6.1.0\lib\StructureMap.dll</HintPath>
4360
</Reference>
@@ -79,6 +96,7 @@
7996
</ItemGroup>
8097
<ItemGroup>
8198
<None Include="app.config" />
99+
<None Include="packages.config" />
82100
</ItemGroup>
83101
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
84102
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

source/ConOverConf.ConsoleHost/Program.cs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class Program
1313
{
1414
static void Main(string[] args)
1515
{
16+
AutoMapperConfiguration.Configure();
17+
1618
//UnityBootstrapper.Setup();
1719
StructureMapBootstrapper.Setup();
1820

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="Iesi.Collections" version="1.0.1" />
4+
<package id="Antlr" version="3.1.3.42154" />
5+
<package id="Castle.Core" version="2.5.1" />
6+
<package id="NHibernate.Core" version="3.0.0.2001" />
7+
<package id="FluentNHibernate" version="1.1.1.694" />
8+
</packages>

source/ConOverConf.Contracts/Data/GameDTO.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace ConOverConf.Contracts.Data
55
{
66
[DataContract]
7-
public class GameDTO
7+
public class GameDTO : QueryResult
88
{
99
[DataMember]
1010
public Guid Id { get; set; }

source/ConOverConf.Contracts/IBackend.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public interface IBackend
99
void SendCommand(Command command);
1010

1111
[OperationContract]
12-
object SendQuery(Query query);
12+
QueryResult SendQuery(Query query);
1313
}
1414
}

source/ConOverConf.Contracts/Queries/GetGame.cs

+1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ public class GetGame : Query<GameDTO>
1111
public Guid Id { get; set; }
1212
}
1313

14+
1415
}

source/ConOverConf.Contracts/Queries/SearchGames.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
namespace ConOverConf.Contracts.Queries
66
{
77
[DataContract]
8-
public class SearchGames : Query<IEnumerable<SearchResultDTO>>
8+
public class SearchGames : Query<SearchGamesResult>
99
{
1010
[DataMember]
1111
public string SearchText { get; set; }
1212
}
13+
14+
[DataContract]
15+
public class SearchGamesResult : QueryResult
16+
{
17+
[DataMember]
18+
public IEnumerable<SearchResultDTO> Hits { get; set; }
19+
}
1320

1421
}

source/ConOverConf.Core/Models/Game.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ namespace ConOverConf.Core.Models
44
{
55
public class Game
66
{
7-
public Guid Id { get; private set; }
8-
public string Title { get; private set; }
9-
public double Rating { get; private set; }
10-
public string Notes { get; private set; }
11-
public string Borrower { get; private set; }
12-
public DateTime AddedOn { get; private set; }
7+
public virtual Guid Id { get; private set; }
8+
public virtual string Title { get; private set; }
9+
public virtual double Rating { get; private set; }
10+
public virtual string Notes { get; private set; }
11+
public virtual string Borrower { get; private set; }
12+
public virtual DateTime AddedOn { get; private set; }
1313

1414
protected Game() { }
1515

@@ -18,6 +18,8 @@ public Game(string title, double rating, string notes)
1818
Title = title;
1919
Rating = rating;
2020
Notes = notes;
21+
22+
AddedOn = DateTime.Now;
2123
}
2224

2325
}

source/ConOverConf.Core/Models/Store.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public virtual void AddEmployee(Employee employee)
2929
Staff.Add(employee);
3030
}
3131

32-
public void MarkAsOpened()
32+
public virtual void MarkAsOpened()
3333
{
3434

3535
}

source/ConOverConf.Handlers/AutoMapperConfiguration.cs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public static class AutoMapperConfiguration
1010
public static void Configure()
1111
{
1212
Mapper.CreateMap<Game, GameDTO>();
13+
Mapper.CreateMap<Game, SearchResultDTO>();
1314

1415
}
1516
}

source/ConOverConf.Handlers/Backend.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ public void SendCommand(Command command)
1313
IoC.Resolve<ICommandInvoker>().Invoke(command);
1414
}
1515

16-
public object SendQuery(Query query)
16+
public QueryResult SendQuery(Query query)
1717
{
1818
return IoC.Resolve<QueryInvoker>().Invoke(query);
1919
}
20+
2021
}
2122
}

source/ConOverConf.Handlers/CommandInvoker.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Transactions;
23
using ConOverConf.Contracts;
34
using ConOverConf.Contracts.Commands;
@@ -8,6 +9,8 @@ public class CommandInvoker : ICommandInvoker
89
{
910
public void Invoke(Command command)
1011
{
12+
Console.WriteLine("Command Received: {0}", command.GetType().Name);
13+
1114
var handlerType = (typeof (IHandleCommand<>)).MakeGenericType(command.GetType());
1215

1316
var handler = IoC.Resolve(handlerType);

source/ConOverConf.Handlers/ConOverConf.Handlers.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
<Project>{67BD9AEE-A520-4E23-B3C8-63C980D9A4F3}</Project>
7272
<Name>ConOverConf.Core</Name>
7373
</ProjectReference>
74+
<ProjectReference Include="..\ConOverConf.Persistence\ConOverConf.Persistence.csproj">
75+
<Project>{C9B0906E-90E4-483B-B510-3A4EB3EF6B77}</Project>
76+
<Name>ConOverConf.Persistence</Name>
77+
</ProjectReference>
7478
</ItemGroup>
7579
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7680
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
using System;
2-
using ConOverConf.Contracts;
1+
2+
using AutoMapper;
3+
using ConOverConf.Contracts.Data;
34
using ConOverConf.Contracts.Queries;
5+
using ConOverConf.Core.Models;
6+
using ConOverConf.Core.Services;
47

58
namespace ConOverConf.Handlers.QueryHandlers
69
{
710
public class GetGameHandler : IHandleQuery<GetGame>
811
{
12+
private readonly IGameRepository _repository;
13+
14+
public GetGameHandler(IGameRepository repository)
15+
{
16+
_repository = repository;
17+
}
18+
919
public object Handle(GetGame query)
1020
{
11-
return null;
21+
var game = _repository.GetBy(query.Id);
22+
23+
return Mapper.Map<Game, GameDTO>(game);
1224
}
1325
}
1426
}

source/ConOverConf.Handlers/QueryHandlers/SearchGamesHandler.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ public SearchGamesHandler(IGameRepository gameRepository)
2121
public object Handle(SearchGames query)
2222
{
2323
var games = _gameRepository.Search(query.SearchText);
24+
25+
var result = new SearchGamesResult();
26+
result.Hits = Mapper.Map<IEnumerable<Game>, IEnumerable<SearchResultDTO>>(games);
2427

25-
return Mapper.Map<IEnumerable<Game>, IEnumerable<GameDTO>>(games);
28+
return result;
2629
}
2730
}
2831
}

source/ConOverConf.Handlers/QueryInvoker.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using ConOverConf.Contracts;
23
using ConOverConf.Contracts.Queries;
34

@@ -6,7 +7,9 @@ namespace ConOverConf.Handlers
67
public class QueryInvoker : IQueryInvoker
78
{
89
public QueryResult Invoke(Query query)
9-
{
10+
{
11+
Console.WriteLine("Query Received: {0}", query.GetType().Name);
12+
1013
var handlerType = (typeof(IHandleQuery<>)).MakeGenericType(query.GetType());
1114

1215
var handler = IoC.Resolve(handlerType);

source/ConOverConf.Persistence/NHSessionFactory.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,31 @@ public static class NHSessionFactory
1818
private static ISessionFactory _sessionFactory;
1919
private const string ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=PimpMyCode;Integrated Security=True;Pooling=False";
2020

21+
// BAD Practice, use WCF OperationContext (just for demo purpose)
22+
[ThreadStatic]
23+
private static ISession _session;
24+
2125
public static ISession GetCurrent()
2226
{
2327
if (_sessionFactory == null)
2428
{
2529
_sessionFactory = BuildSessionFactory(); // normally you would have thread locks around this
2630
}
2731

32+
if (_session == null)
33+
{
34+
_session = _sessionFactory.OpenSession();
35+
_session.FlushMode = FlushMode.Commit;
36+
}
2837

29-
// normaly you would have a session store (per-request or something, store it in WCF OperationContext)
30-
return _sessionFactory.OpenSession();
38+
return _session;
3139
}
3240

3341
private static ISessionFactory BuildSessionFactory()
3442
{
35-
return BuildNHibernateConfiguration().BuildSessionFactory();
43+
var config = BuildNHibernateConfiguration();
44+
45+
return config.BuildSessionFactory();
3646
}
3747

3848
private static Configuration BuildNHibernateConfiguration()
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application x:Class="ConOverConf.SimpleMVVM.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<Application.Resources>
6+
7+
</Application.Resources>
8+
</Application>
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Windows;
7+
8+
namespace ConOverConf.SimpleMVVM
9+
{
10+
/// <summary>
11+
/// Interaction logic for App.xaml
12+
/// </summary>
13+
public partial class App : Application
14+
{
15+
}
16+
}

0 commit comments

Comments
 (0)