Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 14 files changed
  • 1 comment
  • 1 contributor
2  src/Castle.Facilities.NHibernate.Tests/App.config
@@ -6,7 +6,7 @@
6 6 </sectionGroup>
7 7 </configSections>
8 8 <connectionStrings>
9   - <add name="test" connectionString="Server=.\SQLEXPRESS;Database=CastleTxTests;Integrated Security=SSPI;"/>
  9 + <add name="test" connectionString="Data Source=DataStore.db;Version=3"/>
10 10 </connectionStrings>
11 11 <NUnit>
12 12 <TestRunner>
12 src/Castle.Facilities.NHibernate.Tests/Castle.Facilities.NHibernate.Tests.csproj
@@ -75,6 +75,12 @@
75 75 <Reference Include="System" />
76 76 <Reference Include="System.configuration" />
77 77 <Reference Include="System.Core" />
  78 + <Reference Include="System.Data.SQLite">
  79 + <HintPath>..\..\packages\System.Data.SQLite.1.0.82.0\lib\net40\System.Data.SQLite.dll</HintPath>
  80 + </Reference>
  81 + <Reference Include="System.Data.SQLite.Linq">
  82 + <HintPath>..\..\packages\System.Data.SQLite.1.0.82.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
  83 + </Reference>
78 84 <Reference Include="System.Transactions" />
79 85 <Reference Include="Microsoft.CSharp" />
80 86 <Reference Include="System.Data" />
@@ -118,6 +124,12 @@
118 124 </ItemGroup>
119 125 <ItemGroup>
120 126 <Content Include="Readme.txt" />
  127 + <Content Include="x64\SQLite.Interop.dll">
  128 + <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  129 + </Content>
  130 + <Content Include="x86\SQLite.Interop.dll">
  131 + <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  132 + </Content>
121 133 </ItemGroup>
122 134 <ItemGroup>
123 135 <ProjectReference Include="..\Castle.Facilities.NHibernate\Castle.Facilities.NHibernate.csproj">
2  src/Castle.Facilities.NHibernate.Tests/Framework/EnsureSchema.cs
@@ -25,7 +25,7 @@ public abstract class EnsureSchema
25 25 [TestFixtureSetUp]
26 26 public void Setup()
27 27 {
28   - var configuration = new ExampleInstaller().ConfigBuilder();
  28 + var configuration = new ExampleInstaller().Config;
29 29 new SchemaUpdate(configuration).Execute(true, true);
30 30 }
31 31 }
14 src/Castle.Facilities.NHibernate.Tests/Init.cs
@@ -26,8 +26,6 @@ namespace Castle.Facilities.NHibernate.Tests
26 26 using Castle.Transactions;
27 27 using Castle.Windsor;
28 28
29   - using FluentNHibernate.Cfg;
30   -
31 29 using NUnit.Framework;
32 30
33 31 using global::NHibernate;
@@ -149,9 +147,9 @@ public Maybe<IInterceptor> Interceptor
149 147 get { return Maybe.None<IInterceptor>(); }
150 148 }
151 149
152   - public Func<Configuration> ConfigBuilder
  150 + public Configuration Config
153 151 {
154   - get { return new ExampleInstaller().ConfigBuilder; }
  152 + get { return new ExampleInstaller().Config; }
155 153 }
156 154
157 155 public void Registered(ISessionFactory factory)
@@ -177,9 +175,9 @@ public Maybe<IInterceptor> Interceptor
177 175 get { return Maybe.None<IInterceptor>(); }
178 176 }
179 177
180   - public Func<Configuration> ConfigBuilder
  178 + public Configuration Config
181 179 {
182   - get { return new ExampleInstaller().ConfigBuilder; }
  180 + get { return new ExampleInstaller().Config; }
183 181 }
184 182
185 183 public void Registered(ISessionFactory factory)
@@ -205,9 +203,9 @@ public Maybe<IInterceptor> Interceptor
205 203 get { return Maybe.None<IInterceptor>(); }
206 204 }
207 205
208   - public Func<Configuration> ConfigBuilder
  206 + public Configuration Config
209 207 {
210   - get { return new ExampleInstaller().ConfigBuilder; }
  208 + get { return new ExampleInstaller().Config; }
211 209 }
212 210
213 211 public void Registered(ISessionFactory factory)
9 src/Castle.Facilities.NHibernate.Tests/TestClasses/ExampleInstaller.cs
@@ -12,8 +12,6 @@
12 12 // See the License for the specific language governing permissions and
13 13 // limitations under the License.
14 14
15   -using System;
16   -
17 15 namespace Castle.Facilities.NHibernate.Tests.TestClasses
18 16 {
19 17 using System.Configuration;
@@ -46,9 +44,9 @@ public Maybe<IInterceptor> Interceptor
46 44 get { return interceptor; }
47 45 }
48 46
49   - public Func<global::NHibernate.Cfg.Configuration> ConfigBuilder
  47 + public global::NHibernate.Cfg.Configuration Config
50 48 {
51   - get { return BuildFluent().BuildConfiguration; }
  49 + get { return BuildFluent().BuildConfiguration(); }
52 50 }
53 51
54 52 public bool IsDefault
@@ -67,8 +65,7 @@ private FluentConfiguration BuildFluent()
67 65 Contract.Assume(connectionString != null, "please set the \"test\" connection string in app.config");
68 66
69 67 return Fluently.Configure()
70   - .Database(MsSqlConfiguration.MsSql2008.DefaultSchema("dbo")
71   - .ConnectionString(connectionString.ConnectionString))
  68 + .Database(SQLiteConfiguration.Standard.ConnectionString(connectionString.ConnectionString))
72 69 .Mappings(m => m.FluentMappings.AddFromAssemblyOf<ThingMap>());
73 70 }
74 71
1  src/Castle.Facilities.NHibernate.Tests/packages.config
@@ -11,4 +11,5 @@
11 11 <package id="Iesi.Collections" version="3.2.0.4000" targetFramework="net40" />
12 12 <package id="NHibernate" version="3.3.1.4000" targetFramework="net40" />
13 13 <package id="NLog" version="2.0.0.2000" targetFramework="net40" />
  14 + <package id="System.Data.SQLite" version="1.0.82.0" targetFramework="net40" />
14 15 </packages>
12 src/Castle.Facilities.NHibernate/INHibernateInstaller.cs
@@ -15,7 +15,6 @@
15 15
16 16 namespace Castle.Facilities.NHibernate
17 17 {
18   - using System;
19 18 using System.Diagnostics.Contracts;
20 19
21 20 using Transactions;
@@ -45,17 +44,10 @@ public interface INHibernateInstaller
45 44 /// </summary>
46 45 Maybe<IInterceptor> Interceptor { get; }
47 46
48   - /// <summary>
49   - /// Build a fluent configuration.
50   - /// </summary>
51   - /// <returns>A non null fluent configuration instance that can
52   - /// be used to further configure NHibernate</returns>
53   - //FluentConfiguration BuildFluent();
54   -
55 47 /// <summary>
56   - /// Returns functions building configuration
  48 + /// Returns NHibernate configuration
57 49 /// </summary>
58   - Func<Configuration> ConfigBuilder { get; }
  50 + Configuration Config { get; }
59 51
60 52 /// <summary>
61 53 /// Call-back to the installer, when the factory is registered
4 src/Castle.Facilities.NHibernate/INHibernateInstallerContract.cs
@@ -49,11 +49,11 @@ public Maybe<IInterceptor> Interceptor
49 49 }
50 50 }
51 51
52   - public Func<Configuration> ConfigBuilder
  52 + public Configuration Config
53 53 {
54 54 get
55 55 {
56   - Contract.Ensures(Contract.Result<Func<Configuration>>() != null);
  56 + Contract.Ensures(Contract.Result<Configuration>() != null);
57 57 throw new NotImplementedException();
58 58 }
59 59 }
19 src/Castle.Facilities.NHibernate/NHibernateFacility.cs
@@ -168,7 +168,7 @@ protected override void Init()
168 168 if (count == 0 || count > 1)
169 169 throw new FacilityException("no INHibernateInstaller has IsDefault = true or many have specified it");
170 170
171   - if (!installers.All(x => !string.IsNullOrEmpty(x.SessionFactoryKey)))
  171 + if (installers.Any(x => string.IsNullOrEmpty(x.SessionFactoryKey)))
172 172 throw new FacilityException("all session factory keys must be non null and non empty strings");
173 173
174 174 VerifyLegacyInterceptors();
@@ -186,7 +186,7 @@ protected override void Init()
186 186 var installed = installers
187 187 .Select(x => new
188 188 {
189   - Config = x.ConfigBuilder(),
  189 + Config = x.Config,
190 190 Instance = x
191 191 })
192 192 .Select(x => new Data { Config = x.Config, Instance = x.Instance, Factory = x.Config.BuildSessionFactory() })
@@ -282,7 +282,7 @@ private ComponentRegistration<T> GetLifeStyle<T>(ComponentRegistration<T> regist
282 282 return registration.Named(baseName + SessionPWRSuffix).LifeStyle.PerWebRequest;
283 283 if (index == 2)
284 284 return registration.Named(baseName + SessionTransientSuffix).LifeStyle.Transient;
285   - goto default; // TODO: kill this goto
  285 + break;
286 286 case DefaultSessionLifeStyleOption.SessionPerWebRequest:
287 287 if (index == 0)
288 288 return registration.Named(baseName + SessionPWRSuffix).LifeStyle.PerWebRequest;
@@ -290,19 +290,20 @@ private ComponentRegistration<T> GetLifeStyle<T>(ComponentRegistration<T> regist
290 290 return registration.Named(baseName + SessionPerTxSuffix).LifeStyle.PerTopTransaction();
291 291 if (index == 2)
292 292 return registration.Named(baseName + SessionTransientSuffix).LifeStyle.Transient;
293   - goto default;
294   - case DefaultSessionLifeStyleOption.SessionTransient:
  293 + break;
  294 + case DefaultSessionLifeStyleOption.SessionTransient:
295 295 if (index == 0)
296 296 return registration.Named(baseName + SessionTransientSuffix).LifeStyle.Transient;
297 297 if (index == 1)
298 298 return registration.Named(baseName + SessionPerTxSuffix).LifeStyle.PerTopTransaction();
299 299 if (index == 2)
300 300 return registration.Named(baseName + SessionPWRSuffix).LifeStyle.PerWebRequest;
301   - goto default;
302   - default:
303   - throw new FacilityException("invalid index passed to GetLifeStyle<T> - please file a bug report");
  301 + break;
  302 + default:
  303 + throw new FacilityException("Unknown default life style - please file a bug report");
304 304 }
305   - }
  305 + throw new FacilityException("Invalid index passed to GetLifeStyle<T> - please file a bug report");
  306 + }
306 307
307 308 private class Data
308 309 {
14 src/samples/NHibernate.AttrExampleConsoleApp/LogLine.cs
... ... @@ -1,3 +1,17 @@
  1 +// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
  2 +//
  3 +// Licensed under the Apache License, Version 2.0 (the "License");
  4 +// you may not use this file except in compliance with the License.
  5 +// You may obtain a copy of the License at
  6 +//
  7 +// http://www.apache.org/licenses/LICENSE-2.0
  8 +//
  9 +// Unless required by applicable law or agreed to in writing, software
  10 +// distributed under the License is distributed on an "AS IS" BASIS,
  11 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 +// See the License for the specific language governing permissions and
  13 +// limitations under the License.
  14 +
1 15 using System;
2 16 using NHibernate.Mapping.Attributes;
3 17
14 src/samples/NHibernate.AttrExampleConsoleApp/Logger.cs
... ... @@ -1,3 +1,17 @@
  1 +// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
  2 +//
  3 +// Licensed under the Apache License, Version 2.0 (the "License");
  4 +// you may not use this file except in compliance with the License.
  5 +// You may obtain a copy of the License at
  6 +//
  7 +// http://www.apache.org/licenses/LICENSE-2.0
  8 +//
  9 +// Unless required by applicable law or agreed to in writing, software
  10 +// distributed under the License is distributed on an "AS IS" BASIS,
  11 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 +// See the License for the specific language governing permissions and
  13 +// limitations under the License.
  14 +
1 15 using System;
2 16 using Castle.Transactions;
3 17
19 src/samples/NHibernate.AttrExampleConsoleApp/NHibInstaller.cs
... ... @@ -1,4 +1,17 @@
1   -using System;
  1 +// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
  2 +//
  3 +// Licensed under the Apache License, Version 2.0 (the "License");
  4 +// you may not use this file except in compliance with the License.
  5 +// You may obtain a copy of the License at
  6 +//
  7 +// http://www.apache.org/licenses/LICENSE-2.0
  8 +//
  9 +// Unless required by applicable law or agreed to in writing, software
  10 +// distributed under the License is distributed on an "AS IS" BASIS,
  11 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 +// See the License for the specific language governing permissions and
  13 +// limitations under the License.
  14 +
2 15 using Castle.Facilities.NHibernate;
3 16 using Castle.Transactions;
4 17 using NHibernate.Cfg;
@@ -26,7 +39,7 @@ public Maybe<IInterceptor> Interceptor
26 39 get { return Maybe.None<IInterceptor>(); }
27 40 }
28 41
29   - public Func<Configuration> ConfigBuilder
  42 + public Configuration Config
30 43 {
31 44 get
32 45 {
@@ -41,7 +54,7 @@ public Func<Configuration> ConfigBuilder
41 54 })
42 55 .AddAssembly(GetType().Assembly)
43 56 .AddInputStream(HbmSerializer.Default.Serialize(GetType().Assembly));
44   - return () => cfg;
  57 + return cfg;
45 58 }
46 59 }
47 60
17 src/samples/NHibernate.AttrExampleConsoleApp/Program.cs
... ... @@ -1,7 +1,16 @@
1   -using System;
2   -using System.Collections.Generic;
3   -using System.Linq;
4   -using System.Text;
  1 +// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
  2 +//
  3 +// Licensed under the Apache License, Version 2.0 (the "License");
  4 +// you may not use this file except in compliance with the License.
  5 +// You may obtain a copy of the License at
  6 +//
  7 +// http://www.apache.org/licenses/LICENSE-2.0
  8 +//
  9 +// Unless required by applicable law or agreed to in writing, software
  10 +// distributed under the License is distributed on an "AS IS" BASIS,
  11 +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 +// See the License for the specific language governing permissions and
  13 +// limitations under the License.
5 14
6 15 namespace NHibernate.AttrExampleConsoleApp
7 16 {
4 src/samples/NHibernate.ExampleConsoleApp/Program.cs
@@ -175,13 +175,13 @@ public Maybe<IInterceptor> Interceptor
175 175 get { return Maybe.None<IInterceptor>(); }
176 176 }
177 177
178   - public Func<Configuration> ConfigBuilder
  178 + public Configuration Config
179 179 {
180 180 get
181 181 {
182 182 return Fluently.Configure()
183 183 .Database(SQLiteConfiguration.Standard.UsingFile("DataStore.db"))
184   - .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibInstaller>()).BuildConfiguration;
  184 + .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibInstaller>()).BuildConfiguration();
185 185 }
186 186 }
187 187

Showing you all comments on commits in this comparison.

Henrik Feldt

I think you are mixing tabs and spaces, making it hard to see the changes -- could you make an addative commit that normalizes spaces?

Something went wrong with that request. Please try again.