Skip to content

Commit

Permalink
#3 Modified EagerFetch extensions not to use FetchingProvider, starte…
Browse files Browse the repository at this point in the history
…d moving Core.Web tests
  • Loading branch information
Lukas Gerbenis committed Oct 2, 2015
1 parent e6284d3 commit 3a038c1
Show file tree
Hide file tree
Showing 34 changed files with 155 additions and 337 deletions.
7 changes: 7 additions & 0 deletions vNext/BetterModules.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "BetterModules.Core.Tests",
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "BetterModules.Sample.Web.Module", "src\BetterModules.Sample.Web.Module\BetterModules.Sample.Web.Module.xproj", "{AD8BA351-BC65-4894-B42F-9AC6618A2998}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "BetterModules.Core.Web.Tests", "test\BetterModules.Core.Web.Tests\BetterModules.Core.Web.Tests.xproj", "{F6A470DD-63AB-4A65-9CC2-622BD2B9B372}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -66,6 +68,10 @@ Global
{AD8BA351-BC65-4894-B42F-9AC6618A2998}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD8BA351-BC65-4894-B42F-9AC6618A2998}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD8BA351-BC65-4894-B42F-9AC6618A2998}.Release|Any CPU.Build.0 = Release|Any CPU
{F6A470DD-63AB-4A65-9CC2-622BD2B9B372}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6A470DD-63AB-4A65-9CC2-622BD2B9B372}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6A470DD-63AB-4A65-9CC2-622BD2B9B372}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6A470DD-63AB-4A65-9CC2-622BD2B9B372}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -80,5 +86,6 @@ Global
{431BEF5E-502D-4B21-B13C-6E917EACC532} = {E97ED681-48EA-4EF1-97F2-EE7E1EEC516B}
{00B11517-DAEB-43AA-B826-B2AA545AE166} = {46ED6C76-1BCC-4177-9A67-492424080985}
{AD8BA351-BC65-4894-B42F-9AC6618A2998} = {E97ED681-48EA-4EF1-97F2-EE7E1EEC516B}
{F6A470DD-63AB-4A65-9CC2-622BD2B9B372} = {46ED6C76-1BCC-4177-9A67-492424080985}
EndGlobalSection
EndGlobal
7 changes: 4 additions & 3 deletions vNext/src/BetterModules.Core.Web/BetterModules.Core.Web.xproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>d5dd9647-f622-4899-b6c6-3210ec7ac86b</ProjectGuid>
<RootNamespace>BetterModules.Core.Web</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
</Project>
2 changes: 1 addition & 1 deletion vNext/src/BetterModules.Core/BetterModules.Core.xproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>False</ProduceOutputsOnBuild>
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,42 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using NHibernate.Linq;

namespace BetterModules.Core.DataAccess.DataContext.Fetching
{
public static class EagerFetch
{
private static IFetchingProvider FetchingProvider { get; }

public static IFetchRequest<TOriginating, TRelated> Fetch<TOriginating, TRelated>(
this IQueryable<TOriginating> query, Expression<Func<TOriginating, TRelated>> relatedObjectSelector)
{
return FetchingProvider.Fetch(query, relatedObjectSelector);
var fetch = EagerFetchingExtensionMethods.Fetch(query, relatedObjectSelector);
return new FetchRequest<TOriginating, TRelated>(fetch);
}

public static IFetchRequest<TOriginating, TRelated> FetchMany<TOriginating, TRelated>(
this IQueryable<TOriginating> query,
Expression<Func<TOriginating, IEnumerable<TRelated>>> relatedObjectSelector)
{
return FetchingProvider.FetchMany(query, relatedObjectSelector);
var fetch = EagerFetchingExtensionMethods.FetchMany(query, relatedObjectSelector);
return new FetchRequest<TOriginating, TRelated>(fetch);
}

public static IFetchRequest<TQueried, TRelated> ThenFetch<TQueried, TFetch, TRelated>(
this IFetchRequest<TQueried, TFetch> query, Expression<Func<TFetch, TRelated>> relatedObjectSelector)
{
return FetchingProvider.ThenFetch(query, relatedObjectSelector);
var impl = query as FetchRequest<TQueried, TFetch>;
var fetch = impl.NhFetchRequest.ThenFetch(relatedObjectSelector);
return new FetchRequest<TQueried, TRelated>(fetch);
}

public static IFetchRequest<TQueried, TRelated> ThenFetchMany<TQueried, TFetch, TRelated>(
this IFetchRequest<TQueried, TFetch> query,
Expression<Func<TFetch, IEnumerable<TRelated>>> relatedObjectSelector)
{
return FetchingProvider.ThenFetchMany(query, relatedObjectSelector);
var impl = query as FetchRequest<TQueried, TFetch>;
var fetch = impl.NhFetchRequest.ThenFetchMany(relatedObjectSelector);
return new FetchRequest<TQueried, TRelated>(fetch);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,25 @@ public class FetchRequest<TQueried, TFetch> : IFetchRequest<TQueried, TFetch>
{
public IEnumerator<TQueried> GetEnumerator()
{
return this.NhFetchRequest.GetEnumerator();
return NhFetchRequest.GetEnumerator();
}

System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return this.NhFetchRequest.GetEnumerator();
return NhFetchRequest.GetEnumerator();
}

public Type ElementType
{
get
{
return this.NhFetchRequest.ElementType;
}
}
public Type ElementType => NhFetchRequest.ElementType;

public Expression Expression
{
get
{
return this.NhFetchRequest.Expression;
}
}
public Expression Expression => NhFetchRequest.Expression;

public IQueryProvider Provider
{
get
{
return this.NhFetchRequest.Provider;
}
}
public IQueryProvider Provider => NhFetchRequest.Provider;

public FetchRequest(INhFetchRequest<TQueried, TFetch> nhFetchRequest)
{
this.NhFetchRequest = nhFetchRequest;
NhFetchRequest = nhFetchRequest;
}

public INhFetchRequest<TQueried, TFetch> NhFetchRequest { get; private set; }
public INhFetchRequest<TQueried, TFetch> NhFetchRequest { get; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using Microsoft.Dnx.Runtime;
using Microsoft.Framework.Logging;

namespace BetterModules.Core.Environment.Assemblies
Expand All @@ -18,6 +19,8 @@ public class DefaultAssemblyLoader : IAssemblyLoader
/// </summary>
private readonly ILogger logger;



/// <summary>
/// Loaded assemblies container.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using BetterModules.Core.Configuration;
using BetterModules.Core.DataAccess;
using BetterModules.Core.DataAccess.DataContext;
using BetterModules.Core.DataAccess.DataContext.Fetching;
using BetterModules.Core.DataAccess.DataContext.Migrations;
using BetterModules.Core.Environment.Assemblies;
using BetterModules.Core.Environment.FileSystem;
Expand Down Expand Up @@ -48,7 +47,6 @@ public static void ConfigureDefaultServices(this IServiceCollection services)
services.AddSingleton<IUnitOfWorkFactory, DefaultUnitOfWorkFactory>();
services.AddSingleton<IMappingResolver, DefaultMappingResolver>();
services.AddSingleton<IWorkingDirectory, DefaultWorkingDirectory>();
services.AddSingleton<IFetchingProvider, DefaultFetchingProvider>();
services.AddSingleton<IPrincipalProvider, DefaultPrincipalProvider>();
services.AddSingleton<IAssemblyManager, DefaultAssemblyManager>();
services.AddSingleton<IVersionChecker, DefaultVersionChecker>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BetterModules.Sample.Module.Models;
using System;
using BetterModules.Sample.Module.Models;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc;

Expand All @@ -16,6 +17,7 @@ public HomeController(ICalculator calculator)
public IActionResult Index()
{
var result = _calculator.FindRoots(1, 4, 4);
var path = Environment.CurrentDirectory;
return View();
}
}
Expand Down
Loading

0 comments on commit 3a038c1

Please sign in to comment.