Permalink
Browse files

INHibernateInstaller configuration returning simplified

  • Loading branch information...
1 parent adda225 commit 706c0e0d4af05e705b3c0dfba9078f5f0dffd525 @akurdyukov committed Sep 9, 2012
@@ -25,7 +25,7 @@ public abstract class EnsureSchema
[TestFixtureSetUp]
public void Setup()
{
- var configuration = new ExampleInstaller().ConfigBuilder();
+ var configuration = new ExampleInstaller().Config;
new SchemaUpdate(configuration).Execute(true, true);
}
}
@@ -26,8 +26,6 @@ namespace Castle.Facilities.NHibernate.Tests
using Castle.Transactions;
using Castle.Windsor;
- using FluentNHibernate.Cfg;
-
using NUnit.Framework;
using global::NHibernate;
@@ -149,9 +147,9 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public Func<Configuration> ConfigBuilder
+ public Configuration Config
{
- get { return new ExampleInstaller().ConfigBuilder; }
+ get { return new ExampleInstaller().Config; }
}
public void Registered(ISessionFactory factory)
@@ -177,9 +175,9 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public Func<Configuration> ConfigBuilder
+ public Configuration Config
{
- get { return new ExampleInstaller().ConfigBuilder; }
+ get { return new ExampleInstaller().Config; }
}
public void Registered(ISessionFactory factory)
@@ -205,9 +203,9 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public Func<Configuration> ConfigBuilder
+ public Configuration Config
{
- get { return new ExampleInstaller().ConfigBuilder; }
+ get { return new ExampleInstaller().Config; }
}
public void Registered(ISessionFactory factory)
@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using System;
-
namespace Castle.Facilities.NHibernate.Tests.TestClasses
{
using System.Configuration;
@@ -46,9 +44,9 @@ public Maybe<IInterceptor> Interceptor
get { return interceptor; }
}
- public Func<global::NHibernate.Cfg.Configuration> ConfigBuilder
+ public global::NHibernate.Cfg.Configuration Config
{
- get { return BuildFluent().BuildConfiguration; }
+ get { return BuildFluent().BuildConfiguration(); }
}
public bool IsDefault
@@ -15,7 +15,6 @@
namespace Castle.Facilities.NHibernate
{
- using System;
using System.Diagnostics.Contracts;
using Transactions;
@@ -45,17 +44,10 @@ public interface INHibernateInstaller
/// </summary>
Maybe<IInterceptor> Interceptor { get; }
- /// <summary>
- /// Build a fluent configuration.
- /// </summary>
- /// <returns>A non null fluent configuration instance that can
- /// be used to further configure NHibernate</returns>
- //FluentConfiguration BuildFluent();
-
/// <summary>
- /// Returns functions building configuration
+ /// Returns NHibernate configuration
/// </summary>
- Func<Configuration> ConfigBuilder { get; }
+ Configuration Config { get; }
/// <summary>
/// Call-back to the installer, when the factory is registered
@@ -49,11 +49,11 @@ public Maybe<IInterceptor> Interceptor
}
}
- public Func<Configuration> ConfigBuilder
+ public Configuration Config
{
get
{
- Contract.Ensures(Contract.Result<Func<Configuration>>() != null);
+ Contract.Ensures(Contract.Result<Configuration>() != null);
throw new NotImplementedException();
}
}
@@ -186,7 +186,7 @@ protected override void Init()
var installed = installers
.Select(x => new
{
- Config = x.ConfigBuilder(),
+ Config = x.Config,
Instance = x
})
.Select(x => new Data { Config = x.Config, Instance = x.Instance, Factory = x.Config.BuildSessionFactory() })
@@ -1,3 +1,17 @@
+// 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;
@@ -1,3 +1,17 @@
+// 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;
@@ -1,4 +1,17 @@
-using System;
+// 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;
@@ -26,7 +39,7 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public Func<Configuration> ConfigBuilder
+ public Configuration Config
{
get
{
@@ -41,7 +54,7 @@ public Func<Configuration> ConfigBuilder
})
.AddAssembly(GetType().Assembly)
.AddInputStream(HbmSerializer.Default.Serialize(GetType().Assembly));
- return () => cfg;
+ return cfg;
}
}
@@ -1,7 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+// 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
{
@@ -175,13 +175,13 @@ public Maybe<IInterceptor> Interceptor
get { return Maybe.None<IInterceptor>(); }
}
- public Func<Configuration> ConfigBuilder
+ public Configuration Config
{
get
{
return Fluently.Configure()
.Database(SQLiteConfiguration.Standard.UsingFile("DataStore.db"))
- .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibInstaller>()).BuildConfiguration;
+ .Mappings(m => m.FluentMappings.AddFromAssemblyOf<NHibInstaller>()).BuildConfiguration();
}
}

0 comments on commit 706c0e0

Please sign in to comment.