Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 30 files changed
  • 1 commit comment
  • 1 contributor
Showing with 557 additions and 47 deletions.
  1. +3 −1 .gitignore
  2. +23 −0 Castle.Facilities.NHibernate.sln
  3. +0 −1  rakefile.rb
  4. +1 −1  src/Castle.Facilities.NHibernate.Tests/App.config
  5. +12 −0 src/Castle.Facilities.NHibernate.Tests/Castle.Facilities.NHibernate.Tests.csproj
  6. +1 −1  src/Castle.Facilities.NHibernate.Tests/Framework/EnsureSchema.cs
  7. +8 −8 src/Castle.Facilities.NHibernate.Tests/Init.cs
  8. +7 −3 src/Castle.Facilities.NHibernate.Tests/TestClasses/ExampleInstaller.cs
  9. +1 −0  src/Castle.Facilities.NHibernate.Tests/packages.config
  10. BIN  src/Castle.Facilities.NHibernate.Tests/x64/SQLite.Interop.dll
  11. BIN  src/Castle.Facilities.NHibernate.Tests/x86/SQLite.Interop.dll
  12. +0 −3  src/Castle.Facilities.NHibernate/Castle.Facilities.NHibernate.csproj
  13. +5 −7 src/Castle.Facilities.NHibernate/INHibernateInstaller.cs
  14. +9 −6 src/Castle.Facilities.NHibernate/INHibernateInstallerContract.cs
  15. +10 −9 src/Castle.Facilities.NHibernate/NHibernateFacility.cs
  16. +0 −1  src/Castle.Facilities.NHibernate/packages.config
  17. +48 −0 src/samples/NHibernate.AttrExampleConsoleApp/LogLine.cs
  18. +50 −0 src/samples/NHibernate.AttrExampleConsoleApp/Logger.cs
  19. +65 −0 src/samples/NHibernate.AttrExampleConsoleApp/NHibInstaller.cs
  20. +133 −0 src/samples/NHibernate.AttrExampleConsoleApp/NHibernate.AttrExampleConsoleApp.csproj
  21. +15 −0 src/samples/NHibernate.AttrExampleConsoleApp/NLog.config
  22. +97 −0 src/samples/NHibernate.AttrExampleConsoleApp/Program.cs
  23. +36 −0 src/samples/NHibernate.AttrExampleConsoleApp/Properties/AssemblyInfo.cs
  24. +3 −0  src/samples/NHibernate.AttrExampleConsoleApp/app.config
  25. +17 −0 src/samples/NHibernate.AttrExampleConsoleApp/packages.config
  26. BIN  src/samples/NHibernate.AttrExampleConsoleApp/x64/SQLite.Interop.dll
  27. BIN  src/samples/NHibernate.AttrExampleConsoleApp/x86/SQLite.Interop.dll
  28. +5 −2 src/samples/NHibernate.ExampleConsoleApp/NHibernate.ExampleConsoleApp.csproj
  29. +7 −4 src/samples/NHibernate.ExampleConsoleApp/Program.cs
  30. +1 −0  src/samples/NHibernate.ExampleConsoleApp/packages.config
View
4 .gitignore
@@ -11,4 +11,6 @@ _ReSharper*
Castle.Facilities.NHibernate.user
* Thumbs.db
*.nupkg
-packages/
+packages/
+*.user
+*.dotCover
View
23 Castle.Facilities.NHibernate.sln
@@ -27,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{DAFBA7
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.AttrExampleConsoleApp", "src\samples\NHibernate.AttrExampleConsoleApp\NHibernate.AttrExampleConsoleApp.csproj", "{BB3642DF-85D3-4A33-9E11-2AC847DA4DED}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -103,11 +105,32 @@ Global
{9B977E07-808A-4773-B378-EB3665679082}.Release|Mixed Platforms.Build.0 = Release|x86
{9B977E07-808A-4773-B378-EB3665679082}.Release|x86.ActiveCfg = Release|x86
{9B977E07-808A-4773-B378-EB3665679082}.Release|x86.Build.0 = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Debug|x86.ActiveCfg = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Debug|x86.Build.0 = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Debug|Any CPU.ActiveCfg = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Debug|Mixed Platforms.Build.0 = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Debug|x86.ActiveCfg = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Debug|x86.Build.0 = Debug|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Release|Any CPU.ActiveCfg = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Release|Mixed Platforms.ActiveCfg = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Release|Mixed Platforms.Build.0 = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Release|x86.ActiveCfg = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.NET40-Release|x86.Build.0 = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Release|Any CPU.ActiveCfg = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Release|Mixed Platforms.Build.0 = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Release|x86.ActiveCfg = Release|x86
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9B977E07-808A-4773-B378-EB3665679082} = {BF42C45F-BC6F-467D-99C3-D104EF605147}
+ {BB3642DF-85D3-4A33-9E11-2AC847DA4DED} = {BF42C45F-BC6F-467D-99C3-D104EF605147}
EndGlobalSection
EndGlobal
View
1  rakefile.rb
@@ -191,7 +191,6 @@ def nuspec_copy(key, glob)
nuspec.dependency "Castle.FactorySupportFacility", "3.0.0.4001"
nuspec.dependency "Castle.Transactions", "3.1.0.18015"
nuspec.dependency "Castle.Facilities.AutoTx", "3.1.0.18015"
- nuspec.dependency "FluentNHibernate", "1.3.0.733"
nuspec.dependency "NHibernate", "3.3.1.4000"
nuspec.framework_assembly "System.Transactions", FRAMEWORK
View
2  src/Castle.Facilities.NHibernate.Tests/App.config
@@ -6,7 +6,7 @@
</sectionGroup>
</configSections>
<connectionStrings>
- <add name="test" connectionString="Server=.\SQLEXPRESS;Database=CastleTxTests;Integrated Security=SSPI;"/>
+ <add name="test" connectionString="Data Source=DataStore.db;Version=3"/>
</connectionStrings>
<NUnit>
<TestRunner>
View
12 src/Castle.Facilities.NHibernate.Tests/Castle.Facilities.NHibernate.Tests.csproj
@@ -75,6 +75,12 @@
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
+ <Reference Include="System.Data.SQLite">
+ <HintPath>..\..\packages\System.Data.SQLite.1.0.82.0\lib\net40\System.Data.SQLite.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Data.SQLite.Linq">
+ <HintPath>..\..\packages\System.Data.SQLite.1.0.82.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
+ </Reference>
<Reference Include="System.Transactions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
@@ -118,6 +124,12 @@
</ItemGroup>
<ItemGroup>
<Content Include="Readme.txt" />
+ <Content Include="x64\SQLite.Interop.dll">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="x86\SQLite.Interop.dll">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Castle.Facilities.NHibernate\Castle.Facilities.NHibernate.csproj">
View
2  src/Castle.Facilities.NHibernate.Tests/Framework/EnsureSchema.cs
@@ -25,7 +25,7 @@ public abstract class EnsureSchema
[TestFixtureSetUp]
public void Setup()
{
- var configuration = new ExampleInstaller().BuildFluent().BuildConfiguration();
+ var configuration = new ExampleInstaller().Config;
new SchemaUpdate(configuration).Execute(true, true);
}
}
View
16 src/Castle.Facilities.NHibernate.Tests/Init.cs
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+using NHibernate.Cfg;
+
namespace Castle.Facilities.NHibernate.Tests
{
using System;
@@ -24,8 +26,6 @@ namespace Castle.Facilities.NHibernate.Tests
using Castle.Transactions;
using Castle.Windsor;
- using FluentNHibernate.Cfg;
-
using NUnit.Framework;
using global::NHibernate;
@@ -147,9 +147,9 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public FluentConfiguration BuildFluent()
+ public Configuration Config
{
- return new ExampleInstaller().BuildFluent();
+ get { return new ExampleInstaller().Config; }
}
public void Registered(ISessionFactory factory)
@@ -175,9 +175,9 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public FluentConfiguration BuildFluent()
+ public Configuration Config
{
- return new ExampleInstaller().BuildFluent();
+ get { return new ExampleInstaller().Config; }
}
public void Registered(ISessionFactory factory)
@@ -203,9 +203,9 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public FluentConfiguration BuildFluent()
+ public Configuration Config
{
- return new ExampleInstaller().BuildFluent();
+ get { return new ExampleInstaller().Config; }
}
public void Registered(ISessionFactory factory)
View
10 src/Castle.Facilities.NHibernate.Tests/TestClasses/ExampleInstaller.cs
@@ -44,6 +44,11 @@ public Maybe<IInterceptor> Interceptor
get { return interceptor; }
}
+ public global::NHibernate.Cfg.Configuration Config
+ {
+ get { return BuildFluent().BuildConfiguration(); }
+ }
+
public bool IsDefault
{
get { return true; }
@@ -54,14 +59,13 @@ public string SessionFactoryKey
get { return Key; }
}
- public FluentConfiguration BuildFluent()
+ private FluentConfiguration BuildFluent()
{
var connectionString = ConfigurationManager.ConnectionStrings["test"];
Contract.Assume(connectionString != null, "please set the \"test\" connection string in app.config");
return Fluently.Configure()
- .Database(MsSqlConfiguration.MsSql2008.DefaultSchema("dbo")
- .ConnectionString(connectionString.ConnectionString))
+ .Database(SQLiteConfiguration.Standard.ConnectionString(connectionString.ConnectionString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ThingMap>());
}
View
1  src/Castle.Facilities.NHibernate.Tests/packages.config
@@ -11,4 +11,5 @@
<package id="Iesi.Collections" version="3.2.0.4000" targetFramework="net40" />
<package id="NHibernate" version="3.3.1.4000" targetFramework="net40" />
<package id="NLog" version="2.0.0.2000" targetFramework="net40" />
+ <package id="System.Data.SQLite" version="1.0.82.0" targetFramework="net40" />
</packages>
View
BIN  src/Castle.Facilities.NHibernate.Tests/x64/SQLite.Interop.dll
Binary file not shown
View
BIN  src/Castle.Facilities.NHibernate.Tests/x86/SQLite.Interop.dll
Binary file not shown
View
3  src/Castle.Facilities.NHibernate/Castle.Facilities.NHibernate.csproj
@@ -87,9 +87,6 @@
<Reference Include="Castle.Windsor">
<HintPath>..\..\packages\Castle.Windsor.3.1.0\lib\net40\Castle.Windsor.dll</HintPath>
</Reference>
- <Reference Include="FluentNHibernate">
- <HintPath>..\..\packages\FluentNHibernate.1.3.0.733\lib\FluentNHibernate.dll</HintPath>
- </Reference>
<Reference Include="Iesi.Collections">
<HintPath>..\..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
</Reference>
View
12 src/Castle.Facilities.NHibernate/INHibernateInstaller.cs
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+
namespace Castle.Facilities.NHibernate
{
using System.Diagnostics.Contracts;
- using Castle.Transactions;
-
- using FluentNHibernate.Cfg;
+ using Transactions;
+ using global::NHibernate.Cfg;
using global::NHibernate;
/// <summary>
@@ -45,11 +45,9 @@ public interface INHibernateInstaller
Maybe<IInterceptor> Interceptor { get; }
/// <summary>
- /// Build a fluent configuration.
+ /// Returns NHibernate configuration
/// </summary>
- /// <returns>A non null fluent configuration instance that can
- /// be used to further configure NHibernate</returns>
- FluentConfiguration BuildFluent();
+ Configuration Config { get; }
/// <summary>
/// Call-back to the installer, when the factory is registered
View
15 src/Castle.Facilities.NHibernate/INHibernateInstallerContract.cs
@@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+using NHibernate.Cfg;
+
namespace Castle.Facilities.NHibernate
{
using System;
@@ -19,8 +21,6 @@ namespace Castle.Facilities.NHibernate
using Castle.Transactions;
- using FluentNHibernate.Cfg;
-
using global::NHibernate;
[ContractClassFor(typeof(INHibernateInstaller))]
@@ -49,10 +49,13 @@ public Maybe<IInterceptor> Interceptor
}
}
- public FluentConfiguration BuildFluent()
+ public Configuration Config
{
- Contract.Ensures(Contract.Result<FluentConfiguration>() != null);
- throw new NotImplementedException();
+ get
+ {
+ Contract.Ensures(Contract.Result<Configuration>() != null);
+ throw new NotImplementedException();
+ }
}
public void Registered(ISessionFactory factory)
View
19 src/Castle.Facilities.NHibernate/NHibernateFacility.cs
@@ -168,7 +168,7 @@ protected override void Init()
if (count == 0 || count > 1)
throw new FacilityException("no INHibernateInstaller has IsDefault = true or many have specified it");
- if (!installers.All(x => !string.IsNullOrEmpty(x.SessionFactoryKey)))
+ if (installers.Any(x => string.IsNullOrEmpty(x.SessionFactoryKey)))
throw new FacilityException("all session factory keys must be non null and non empty strings");
VerifyLegacyInterceptors();
@@ -186,7 +186,7 @@ protected override void Init()
var installed = installers
.Select(x => new
{
- Config = x.BuildFluent().BuildConfiguration(),
+ Config = x.Config,
Instance = x
})
.Select(x => new Data { Config = x.Config, Instance = x.Instance, Factory = x.Config.BuildSessionFactory() })
@@ -237,7 +237,7 @@ protected override void Init()
private IRegistration RegisterStatelessSession(Data x, uint index)
{
Contract.Requires(index < 3,
- "there are only three supported lifestyles; per transaction, per web request and transient");
+ "there are only three supported lifestyles; per transaction, per web request and transient");
Contract.Requires(x != null);
Contract.Ensures(Contract.Result<IRegistration>() != null);
@@ -250,7 +250,7 @@ private IRegistration RegisterStatelessSession(Data x, uint index)
private IRegistration RegisterSession(Data x, uint index)
{
Contract.Requires(index < 3,
- "there are only three supported lifestyles; per transaction, per web request and transient");
+ "there are only three supported lifestyles; per transaction, per web request and transient");
Contract.Requires(x != null);
Contract.Ensures(Contract.Result<IRegistration>() != null);
@@ -270,7 +270,7 @@ private ComponentRegistration<T> GetLifeStyle<T>(ComponentRegistration<T> regist
where T : class
{
Contract.Requires(index < 3,
- "there are only three supported lifestyles; per transaction, per web request and transient");
+ "there are only three supported lifestyles; per transaction, per web request and transient");
Contract.Ensures(Contract.Result<ComponentRegistration<T>>() != null);
switch (defaultLifeStyle)
@@ -282,7 +282,7 @@ private ComponentRegistration<T> GetLifeStyle<T>(ComponentRegistration<T> regist
return registration.Named(baseName + SessionPWRSuffix).LifeStyle.PerWebRequest;
if (index == 2)
return registration.Named(baseName + SessionTransientSuffix).LifeStyle.Transient;
- goto default;
+ break;
case DefaultSessionLifeStyleOption.SessionPerWebRequest:
if (index == 0)
return registration.Named(baseName + SessionPWRSuffix).LifeStyle.PerWebRequest;
@@ -290,7 +290,7 @@ private ComponentRegistration<T> GetLifeStyle<T>(ComponentRegistration<T> regist
return registration.Named(baseName + SessionPerTxSuffix).LifeStyle.PerTopTransaction();
if (index == 2)
return registration.Named(baseName + SessionTransientSuffix).LifeStyle.Transient;
- goto default;
+ break;
case DefaultSessionLifeStyleOption.SessionTransient:
if (index == 0)
return registration.Named(baseName + SessionTransientSuffix).LifeStyle.Transient;
@@ -298,10 +298,11 @@ private ComponentRegistration<T> GetLifeStyle<T>(ComponentRegistration<T> regist
return registration.Named(baseName + SessionPerTxSuffix).LifeStyle.PerTopTransaction();
if (index == 2)
return registration.Named(baseName + SessionPWRSuffix).LifeStyle.PerWebRequest;
- goto default;
+ break;
default:
- throw new FacilityException("invalid index passed to GetLifeStyle<T> - please file a bug report");
+ throw new FacilityException("Unknown default life style - please file a bug report");
}
+ throw new FacilityException("Invalid index passed to GetLifeStyle<T> - please file a bug report");
}
private class Data
View
1  src/Castle.Facilities.NHibernate/packages.config
@@ -6,7 +6,6 @@
<package id="Castle.LoggingFacility" version="3.1.0" targetFramework="net40" />
<package id="Castle.Transactions" version="3.2.207.2207" targetFramework="net40" />
<package id="Castle.Windsor" version="3.1.0" targetFramework="net40" />
- <package id="FluentNHibernate" version="1.3.0.733" targetFramework="net40" />
<package id="Iesi.Collections" version="3.2.0.4000" targetFramework="net40" />
<package id="NHibernate" version="3.3.1.4000" targetFramework="net40" />
</packages>
View
48 src/samples/NHibernate.AttrExampleConsoleApp/LogLine.cs
@@ -0,0 +1,48 @@
+// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System;
+using NHibernate.Mapping.Attributes;
+
+namespace NHibernate.AttrExampleConsoleApp
+{
+ [Serializable]
+ [Class(Table = "LOGLINES")]
+ public class LogLine
+ {
+ /// <summary>
+ /// Gets the ID of the line in the log.
+ /// </summary>
+ [Id(Name = "Id", Column = "ID")]
+ [Generator(1, Class = "guid.comb")]
+ public virtual Guid Id { get; protected set; }
+
+ /// <summary>
+ /// Gets the log-line.
+ /// </summary>
+ [Property(Column = "LINE", NotNull = true, TypeType = typeof(string))]
+ public virtual string Line { get; protected set; }
+
+ /// <summary> for serialization </summary>
+ [Obsolete("for serialization")]
+ protected LogLine()
+ {
+ }
+
+ public LogLine(string line)
+ {
+ Line = line;
+ }
+ }
+}
View
50 src/samples/NHibernate.AttrExampleConsoleApp/Logger.cs
@@ -0,0 +1,50 @@
+// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System;
+using Castle.Transactions;
+
+namespace NHibernate.AttrExampleConsoleApp
+{
+ public class Logger
+ {
+ private readonly Func<ISession> getSession;
+
+ public Logger(Func<ISession> getSession)
+ {
+ this.getSession = getSession;
+ }
+
+ [Transaction]
+ public virtual void WriteToLog(string text)
+ {
+ using (var s = getSession())
+ {
+ s.Save(new LogLine(text));
+ }
+ }
+
+ [Transaction]
+ public virtual void ReadLog(Action<string> reader)
+ {
+ using (var s = getSession())
+ {
+ foreach (var line in s.CreateCriteria<LogLine>().List<LogLine>())
+ {
+ reader(line.Line);
+ }
+ }
+ }
+ }
+}
View
65 src/samples/NHibernate.AttrExampleConsoleApp/NHibInstaller.cs
@@ -0,0 +1,65 @@
+// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using Castle.Facilities.NHibernate;
+using Castle.Transactions;
+using NHibernate.Cfg;
+using NHibernate.Connection;
+using NHibernate.Dialect;
+using NHibernate.Driver;
+using NHibernate.Mapping.Attributes;
+
+namespace NHibernate.AttrExampleConsoleApp
+{
+ internal class NHibInstaller : INHibernateInstaller
+ {
+ public bool IsDefault
+ {
+ get { return true; }
+ }
+
+ public string SessionFactoryKey
+ {
+ get { return "def"; }
+ }
+
+ public Maybe<IInterceptor> Interceptor
+ {
+ get { return Maybe.None<IInterceptor>(); }
+ }
+
+ public Configuration Config
+ {
+ get
+ {
+ HbmSerializer.Default.Validate = true;
+ Configuration cfg = new Configuration()
+ .DataBaseIntegration(db =>
+ {
+ db.ConnectionString = "Data Source=DataStore.db;Version=3";
+ db.Dialect<SQLiteDialect>();
+ db.Driver<SQLite20Driver>();
+ db.ConnectionProvider<DriverConnectionProvider>();
+ })
+ .AddAssembly(GetType().Assembly)
+ .AddInputStream(HbmSerializer.Default.Serialize(GetType().Assembly));
+ return cfg;
+ }
+ }
+
+ public void Registered(ISessionFactory factory)
+ {
+ }
+ }
+}
View
133 src/samples/NHibernate.AttrExampleConsoleApp/NHibernate.AttrExampleConsoleApp.csproj
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{BB3642DF-85D3-4A33-9E11-2AC847DA4DED}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>NHibernate.AttrExampleConsoleApp</RootNamespace>
+ <AssemblyName>NHibernate.AttrExampleConsoleApp</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>
+ </TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Castle.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Castle.Core.3.1.0\lib\net40-client\Castle.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Facilities.AutoTx, Version=3.2.207.2207, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Castle.Facilities.AutoTx.3.2.207.2207\lib\net40\Castle.Facilities.AutoTx.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Facilities.FactorySupport, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Castle.FactorySupportFacility.3.1.0\lib\net40\Castle.Facilities.FactorySupport.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Facilities.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Castle.LoggingFacility.3.1.0\lib\net40\Castle.Facilities.Logging.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Services.Logging.NLogIntegration, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Castle.Core-NLog.3.1.0\lib\net40-client\Castle.Services.Logging.NLogIntegration.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Transactions, Version=3.2.207.2207, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Castle.Transactions.3.2.207.2207\lib\net40\Castle.Transactions.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Windsor, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Castle.Windsor.3.1.0\lib\net40\Castle.Windsor.dll</HintPath>
+ </Reference>
+ <Reference Include="Iesi.Collections">
+ <HintPath>..\..\..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll</HintPath>
+ </Reference>
+ <Reference Include="NHibernate">
+ <HintPath>..\..\..\packages\NHibernate.3.3.1.4000\lib\Net35\NHibernate.dll</HintPath>
+ </Reference>
+ <Reference Include="NHibernate.Mapping.Attributes">
+ <HintPath>..\..\..\packages\NHibernate.Mapping.Attributes.3.2.0.0\lib\NHibernate.Mapping.Attributes.dll</HintPath>
+ </Reference>
+ <Reference Include="NLog">
+ <HintPath>..\..\..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data.SQLite, Version=1.0.82.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\System.Data.SQLite.1.0.82.0\lib\net40\System.Data.SQLite.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Data.SQLite.Linq">
+ <HintPath>..\..\..\packages\System.Data.SQLite.1.0.82.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Transactions" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Topshelf, Version=3.0.104.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\packages\Topshelf.3.0.1\lib\net40-full\Topshelf.dll</HintPath>
+ </Reference>
+ <Reference Include="Topshelf.NLog">
+ <HintPath>..\..\..\packages\Topshelf.NLog.3.0.1\lib\net40-full\Topshelf.NLog.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Logger.cs" />
+ <Compile Include="LogLine.cs" />
+ <Compile Include="NHibInstaller.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Castle.Facilities.NHibernate\Castle.Facilities.NHibernate.csproj">
+ <Project>{12598D2B-B68E-4EA7-A7DD-0CC2398CE8B6}</Project>
+ <Name>Castle.Facilities.NHibernate</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="NLog.config">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="x64\SQLite.Interop.dll">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="x86\SQLite.Interop.dll">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
15 src/samples/NHibernate.AttrExampleConsoleApp/NLog.config
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <!-- make sure to set 'Copy To Output Directory' option for this file -->
+ <!-- go to http://nlog-project.org/wiki/Configuration_file for more information -->
+
+ <targets>
+ <target xsi:type="ColoredConsole" name="Console"/>
+ </targets>
+
+ <rules>
+ <logger name="*" writeTo="Console" />
+ </rules>
+</nlog>
View
97 src/samples/NHibernate.AttrExampleConsoleApp/Program.cs
@@ -0,0 +1,97 @@
+// Copyright 2004-2011 Castle Project - http://www.castleproject.org/
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace NHibernate.AttrExampleConsoleApp
+{
+ using System;
+
+ using Castle.Facilities.AutoTx;
+ using Castle.Facilities.AutoTx.Testing;
+ using Castle.Facilities.NHibernate;
+ using Castle.MicroKernel.Registration;
+ using Castle.Windsor;
+
+ using NHibernate.Cfg;
+ using NHibernate.Tool.hbm2ddl;
+
+ using NLog;
+
+ using Topshelf;
+ using Castle.Facilities.Logging;
+
+ internal class Program
+ {
+ private static void Main(string[] args)
+ {
+ // log4net.ConfigBasicConfigurator.Configure(); // supporting topshelf & its logging to log4net - enable if you want detailed logs
+ HostFactory.Run(cfg =>
+ {
+ cfg.UseNLog();
+ cfg.RunAsNetworkService();
+
+ cfg.SetDescription("A service logging when it starts and stops to SQLite.");
+ cfg.SetDisplayName("NHibernate Logger");
+ cfg.SetServiceName("nhibLogger");
+
+ cfg.Service<Program>(s =>
+ {
+ s.ConstructUsing(() => new Program());
+ s.WhenStarted(p => p.Start());
+ s.WhenStopped(p => p.Stop());
+ });
+ });
+ }
+
+ private IWindsorContainer container;
+
+ private void Start()
+ {
+ container = new WindsorContainer();
+ container.AddFacility<LoggingFacility>(f => f.UseNLog());
+
+ container
+ .AddFacility<AutoTxFacility>()
+ .Register(
+ Component.For<INHibernateInstaller>().ImplementedBy<NHibInstaller>().LifeStyle.Singleton,
+ Component.For<Logger>().LifeStyle.Singleton)
+ .AddFacility<NHibernateFacility>();
+
+ using (var scope = new ResolveScope<Logger>(container))
+ {
+ using (var up = new ResolveScope<Configuration>(container))
+ {
+ new SchemaUpdate(up.Service).Execute(false, true);
+ }
+
+ Console.WriteLine("Current log contents:");
+ Console.WriteLine("[utc date] - [text]");
+ Console.WriteLine("-------------------");
+ scope.Service.ReadLog(Console.WriteLine); // read everything from saved log
+ scope.Service.WriteToLog(string.Format("{0} - Started", DateTime.UtcNow)); // write simple line to log
+ }
+ }
+
+ private void Stop()
+ {
+ using (var scope = new ResolveScope<Logger>(container))
+ scope.Service.WriteToLog(string.Format("{0} - Stopped", DateTime.UtcNow));
+
+ foreach (var target in LogManager.Configuration.AllTargets)
+ target.Dispose();
+
+ container.Dispose();
+ container = null;
+ }
+ }
+}
View
36 src/samples/NHibernate.AttrExampleConsoleApp/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("NHibernate.AttrExampleConsoleApp")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("NHibernate.AttrExampleConsoleApp")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("47fac674-3a17-4fe4-a5f2-5fb751188e74")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
3  src/samples/NHibernate.AttrExampleConsoleApp/app.config
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
View
17 src/samples/NHibernate.AttrExampleConsoleApp/packages.config
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Castle.Core" version="3.1.0" targetFramework="net40" />
+ <package id="Castle.Core-NLog" version="3.1.0" targetFramework="net40" />
+ <package id="Castle.Facilities.AutoTx" version="3.2.207.2207" targetFramework="net40" />
+ <package id="Castle.FactorySupportFacility" version="3.1.0" targetFramework="net40" />
+ <package id="Castle.LoggingFacility" version="3.1.0" targetFramework="net40" />
+ <package id="Castle.Transactions" version="3.2.207.2207" targetFramework="net40" />
+ <package id="Castle.Windsor" version="3.1.0" targetFramework="net40" />
+ <package id="Iesi.Collections" version="3.2.0.4000" targetFramework="net40" />
+ <package id="NHibernate" version="3.3.1.4000" targetFramework="net40" />
+ <package id="NHibernate.Mapping.Attributes" version="3.2.0.0" targetFramework="net40" />
+ <package id="NLog" version="2.0.0.2000" targetFramework="net40" />
+ <package id="System.Data.SQLite" version="1.0.82.0" targetFramework="net40" />
+ <package id="Topshelf" version="3.0.1" targetFramework="net40" />
+ <package id="Topshelf.NLog" version="3.0.1" targetFramework="net40" />
+</packages>
View
BIN  src/samples/NHibernate.AttrExampleConsoleApp/x64/SQLite.Interop.dll
Binary file not shown
View
BIN  src/samples/NHibernate.AttrExampleConsoleApp/x86/SQLite.Interop.dll
Binary file not shown
View
7 src/samples/NHibernate.ExampleConsoleApp/NHibernate.ExampleConsoleApp.csproj
@@ -37,7 +37,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Castle.Core">
+ <Reference Include="Castle.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Castle.Core.3.1.0\lib\net40-client\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Facilities.AutoTx, Version=3.2.207.2207, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
@@ -50,11 +50,14 @@
<Reference Include="Castle.Facilities.Logging">
<HintPath>..\..\..\packages\Castle.LoggingFacility.3.1.0\lib\net40\Castle.Facilities.Logging.dll</HintPath>
</Reference>
+ <Reference Include="Castle.Services.Logging.NLogIntegration">
+ <HintPath>..\..\..\packages\Castle.Core-NLog.3.1.0\lib\net40-client\Castle.Services.Logging.NLogIntegration.dll</HintPath>
+ </Reference>
<Reference Include="Castle.Transactions, Version=3.2.207.2207, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Castle.Transactions.3.2.207.2207\lib\net40\Castle.Transactions.dll</HintPath>
</Reference>
- <Reference Include="Castle.Windsor">
+ <Reference Include="Castle.Windsor, Version=3.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Castle.Windsor.3.1.0\lib\net40\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="FluentNHibernate">
View
11 src/samples/NHibernate.ExampleConsoleApp/Program.cs
@@ -175,11 +175,14 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public FluentConfiguration BuildFluent()
+ public Configuration Config
{
- return Fluently.Configure()
- .Database(SQLiteConfiguration.Standard.UsingFile("DataStore.db"))
- .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibInstaller>());
+ get
+ {
+ return Fluently.Configure()
+ .Database(SQLiteConfiguration.Standard.UsingFile("DataStore.db"))
+ .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibInstaller>()).BuildConfiguration();
+ }
}
public void Registered(ISessionFactory factory)
View
1  src/samples/NHibernate.ExampleConsoleApp/packages.config
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="3.1.0" targetFramework="net40" />
+ <package id="Castle.Core-NLog" version="3.1.0" targetFramework="net40" />
<package id="Castle.Facilities.AutoTx" version="3.2.207.2207" targetFramework="net40" />
<package id="Castle.FactorySupportFacility" version="3.1.0" targetFramework="net40" />
<package id="Castle.LoggingFacility" version="3.1.0" targetFramework="net40" />

Showing you all comments on commits in this comparison.

@haf

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.