Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 11 commits
  • 19 files changed
  • 0 commit comments
  • 3 contributors
View
2  .gitignore
@@ -24,3 +24,5 @@ src/*/*/test-results/*.xml
*.cache
*.pidb
*~
+*.dotCover
+*.Resharper
View
4 src/mindtouch.core/DreamHostService.cs
@@ -266,7 +266,7 @@ internal class ServiceEntry {
public DreamHostService() : this(null) { }
public DreamHostService(IContainer container) {
- _container = (container ?? new ContainerBuilder().Build());
+ _container = (container ?? new ContainerBuilder().Build(ContainerBuildOptions.Default));
_hostLifetimeScope = _container.BeginLifetimeScope(DreamContainerScope.Host);
}
@@ -1093,7 +1093,7 @@ internal class ServiceEntry {
}
_serviceLifetimeScopes.Clear();
}
- _container.Dispose();
+ _hostLifetimeScope.Dispose();
}
}
View
2  src/mindtouch.core/serviceactivator.cs
@@ -52,7 +52,7 @@ internal class DefaultServiceActivator : IServiceActivator {
}
public IDreamService Create(XDoc config, Type type) {
object service;
- if(!_lifetimeScope.TryResolve(new TypedService(type), new[] { TypedParameter.From(config) }, out service)) {
+ if(!_lifetimeScope.TryResolveService(new TypedService(type), new[] { TypedParameter.From(config) }, out service)) {
service = Activator.CreateInstance(type);
}
return (IDreamService)service;
View
1  src/mindtouch.dream.test/DreamTestHelper.cs
@@ -21,6 +21,7 @@
using System;
using System.Threading;
using Autofac;
+using Autofac.Builder;
using log4net;
using MindTouch.Tasking;
using MindTouch.Xml;
View
4 src/mindtouch.dream/system/datetimeutil.cs
@@ -42,9 +42,7 @@ public static class DateTimeUtil {
/// </summary>
public static DateTime UtcToday {
get {
- DateTime result = DateTime.Today.ToUniversalTime();
- result = result.AddHours(-result.Hour);
- return result;
+ return DateTime.UtcNow.Date;
}
}
View
14 src/mindtouch.host/App.config
@@ -5,6 +5,7 @@
</configSections>
<appSettings>
<add key="threadpool" value="elastic" />
+ <add key="log4net.Config" value="log4net.config"/>
</appSettings>
<system.net>
<connectionManagement>
@@ -12,19 +13,6 @@
<add address="*" maxconnection="16" />
</connectionManagement>
</system.net>
- <log4net>
- <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
- <layout type="log4net.Layout.PatternLayout">
- <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
- </layout>
- </appender>
- <renderer renderingClass="MindTouch.Logging.ExceptionRenderer" renderedClass="System.Exception" />
- <!-- Set root logger level to DEBUG and its only appender to A1 -->
- <root>
- <level value="WARN" />
- <appender-ref ref="ConsoleAppender" />
- </root>
- </log4net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
View
14 src/mindtouch.host/log4net.config
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<log4net>
+ <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
+ <layout type="log4net.Layout.PatternLayout">
+ <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
+ </layout>
+ </appender>
+ <renderer renderingClass="MindTouch.Logging.ExceptionRenderer" renderedClass="System.Exception" />
+ <!-- Set root logger level to WARN and its only appender to ConsoleAppender -->
+ <root>
+ <level value="WARN" />
+ <appender-ref ref="ConsoleAppender" />
+ </root>
+</log4net>
View
3  src/mindtouch.host/mindtouch.host.csproj
@@ -62,6 +62,9 @@
<ItemGroup>
<None Include="App.config">
</None>
+ <None Include="log4net.config">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Content Include="mindtouch.env.xml">
View
BIN  src/redist/Autofac.Configuration.dll
Binary file not shown
View
2,082 src/redist/Autofac.XML
1,672 additions, 410 deletions not shown
View
BIN  src/redist/Autofac.dll
Binary file not shown
View
13 src/tests/DreamMisc/AutofacTests.cs
@@ -20,6 +20,7 @@
*/
using Autofac;
+using Autofac.Builder;
using Autofac.Core;
using NUnit.Framework;
@@ -30,7 +31,7 @@ public class AutofacTests {
[Test]
public void Last_registration_wins() {
- var hostScope = new ContainerBuilder().Build().BeginLifetimeScope(DreamContainerScope.Host);
+ var hostScope = new ContainerBuilder().Build(ContainerBuildOptions.Default).BeginLifetimeScope(DreamContainerScope.Host);
var serviceScope = hostScope.BeginLifetimeScope(DreamContainerScope.Service, b => {
b.RegisterType<Foo>().As<IFoo>().ServiceScoped();
b.RegisterType<Fu>().As<IFoo>().ServiceScoped();
@@ -41,7 +42,7 @@ public class AutofacTests {
[Test]
public void Last_registration_wins_with_module() {
- var hostScope = new ContainerBuilder().Build().BeginLifetimeScope(DreamContainerScope.Host);
+ var hostScope = new ContainerBuilder().Build(ContainerBuildOptions.Default).BeginLifetimeScope(DreamContainerScope.Host);
var serviceScope = hostScope.BeginLifetimeScope(DreamContainerScope.Service, b => {
b.RegisterModule(new FuModule());
b.RegisterType<Foo>().As<IFoo>().ServiceScoped();
@@ -52,7 +53,7 @@ public class AutofacTests {
[Test]
public void Last_module_wins() {
- var hostScope = new ContainerBuilder().Build().BeginLifetimeScope(DreamContainerScope.Host);
+ var hostScope = new ContainerBuilder().Build(ContainerBuildOptions.Default).BeginLifetimeScope(DreamContainerScope.Host);
var serviceScope = hostScope.BeginLifetimeScope(DreamContainerScope.Service, b => {
b.RegisterModule(new FooModule());
b.RegisterModule(new FuModule());
@@ -63,7 +64,7 @@ public class AutofacTests {
[Test]
public void Can_register_service_level_component_at_service_scope_creation_and_resolve_in_service_scope() {
- var hostScope = new ContainerBuilder().Build().BeginLifetimeScope(DreamContainerScope.Host);
+ var hostScope = new ContainerBuilder().Build(ContainerBuildOptions.Default).BeginLifetimeScope(DreamContainerScope.Host);
var serviceScope = hostScope.BeginLifetimeScope(DreamContainerScope.Service, b => b.RegisterType<Foo>().As<IFoo>().ServiceScoped());
var foo = serviceScope.Resolve<IFoo>();
Assert.IsNotNull(foo);
@@ -71,7 +72,7 @@ public class AutofacTests {
[Test]
public void Can_register_request_level_component_at_service_scope_creation_and_resolve_in_request_scope() {
- var hostScope = new ContainerBuilder().Build().BeginLifetimeScope(DreamContainerScope.Host);
+ var hostScope = new ContainerBuilder().Build(ContainerBuildOptions.Default).BeginLifetimeScope(DreamContainerScope.Host);
var serviceScope = hostScope.BeginLifetimeScope(DreamContainerScope.Service, b => b.RegisterType<Foo>().As<IFoo>().RequestScoped());
var requestScope = serviceScope.BeginLifetimeScope(DreamContainerScope.Request);
var foo = requestScope.Resolve<IFoo>();
@@ -80,7 +81,7 @@ public class AutofacTests {
[Test]
public void Cannot_resolve_RequestScoped_component_registered_at_service_scope_creation_in_service_scope() {
- var hostScope = new ContainerBuilder().Build().BeginLifetimeScope(DreamContainerScope.Host);
+ var hostScope = new ContainerBuilder().Build(ContainerBuildOptions.Default).BeginLifetimeScope(DreamContainerScope.Host);
var serviceScope = hostScope.BeginLifetimeScope(DreamContainerScope.Service, b => b.RegisterType<Foo>().As<IFoo>().RequestScoped());
try {
var foo = serviceScope.Resolve<IFoo>();
View
9 src/tests/DreamMisc/ContainerTests.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using Autofac;
+using Autofac.Builder;
using MindTouch.Dream.Test.ContainerTestClasses;
using MindTouch.Tasking;
using MindTouch.Xml;
@@ -37,7 +38,7 @@ public class ContainerTests {
public void Can_set_request_scope_registration_on_provided_container() {
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>().InScope(DreamContainerScope.Request);
- var hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build());
+ var hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build(ContainerBuildOptions.Default));
var service = hostInfo.CreateService(typeof(ContainerTestService), "test");
CheckResponse(service.AtLocalHost.At("scope").Get(new Result<DreamMessage>()).Wait());
var requestScope1 = ContainerTestService.Scoped;
@@ -52,7 +53,7 @@ public class ContainerTests {
public void Can_set_service_scope_registration_on_provided_container() {
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>().InScope(DreamContainerScope.Service);
- var hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build());
+ var hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build(ContainerBuildOptions.Default));
var service = hostInfo.CreateService(typeof(ContainerTestService), "test");
CheckResponse(service.AtLocalHost.At("scope").Get(new Result<DreamMessage>()).Wait());
var serviceScope1 = ContainerTestService.Scoped;
@@ -67,7 +68,7 @@ public class ContainerTests {
public void Can_set_service_scope_registration_on_provided_container2() {
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>().InScope(DreamContainerScope.Service);
- var hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build());
+ var hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build(ContainerBuildOptions.Default));
var service1 = hostInfo.CreateService(typeof(ContainerTestService), "test");
var service2 = hostInfo.CreateService(typeof(ContainerTestService), "test");
CheckResponse(service1.AtLocalHost.At("scope").Get(new Result<DreamMessage>()).Wait());
@@ -83,7 +84,7 @@ public class ContainerTests {
public void Can_set_host_scope_registration_on_provided_container() {
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>().InScope(DreamContainerScope.Host);
- var hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build());
+ var hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build(ContainerBuildOptions.Default));
var service1 = hostInfo.CreateService(typeof(ContainerTestService), "test");
var service2 = hostInfo.CreateService(typeof(ContainerTestService), "test");
CheckResponse(service1.AtLocalHost.At("scope").Get(new Result<DreamMessage>()).Wait());
View
3  src/tests/DreamMisc/DreamFeatureTests.cs
@@ -24,6 +24,7 @@
using System.Linq;
using System.Text;
using Autofac;
+using Autofac.Builder;
using log4net;
using MindTouch.Tasking;
using MindTouch.Web;
@@ -48,7 +49,7 @@ public class Foo : IFoo { }
public void Init() {
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>().RequestScoped();
- _hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"),builder.Build());
+ _hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config"), builder.Build(ContainerBuildOptions.Default));
_hostInfo.Host.Self.At("load").With("name", "test.mindtouch.dream").Post(DreamMessage.Ok());
var config = new XDoc("config")
.Elem("path", "test")
View
41 src/tests/DreamMisc/XDocAutofacContainerConfiguratorTests.cs
@@ -21,6 +21,7 @@
using System;
using Autofac;
+using Autofac.Builder;
using Autofac.Core;
using Autofac.Core.Registration;
using MindTouch.Xml;
@@ -38,7 +39,7 @@ public class XDocAutofacContainerConfiguratorTests {
[SetUp]
public void Setup() {
- _hostContainer = new ContainerBuilder().Build().BeginLifetimeScope(DreamContainerScope.Host);
+ _hostContainer = new ContainerBuilder().Build(ContainerBuildOptions.Default).BeginLifetimeScope(DreamContainerScope.Host);
_serviceContainer = _hostContainer.BeginLifetimeScope(DreamContainerScope.Service);
_requestContainer = _serviceContainer.BeginLifetimeScope(DreamContainerScope.Request);
}
@@ -140,27 +141,27 @@ public class XDocAutofacContainerConfiguratorTests {
break;
case DreamContainerScope.Host:
Assert.AreEqual(InstanceSharing.Shared, registration.Sharing);
- Assert.IsTrue(_hostContainer.TryResolve(new TypedService(type), out instance), "unable to resolve in host");
- Assert.IsTrue(_serviceContainer.TryResolve(new TypedService(type), out instance), "unable to resolve in service");
- Assert.IsTrue(_requestContainer.TryResolve(new TypedService(type), out instance), "unable to resolve in request");
+ Assert.IsTrue(_hostContainer.TryResolveService(new TypedService(type), out instance), "unable to resolve in host");
+ Assert.IsTrue(_serviceContainer.TryResolveService(new TypedService(type), out instance), "unable to resolve in service");
+ Assert.IsTrue(_requestContainer.TryResolveService(new TypedService(type), out instance), "unable to resolve in request");
break;
case DreamContainerScope.Service:
Assert.AreEqual(InstanceSharing.Shared, registration.Sharing);
try {
- Assert.IsFalse(_hostContainer.TryResolve(new TypedService(type), out instance), "able to resolve in host");
+ Assert.IsFalse(_hostContainer.TryResolveService(new TypedService(type), out instance), "able to resolve in host");
} catch(DependencyResolutionException) {}
- Assert.IsTrue(_serviceContainer.TryResolve(new TypedService(type), out instance), "unable to resolve in service");
- Assert.IsTrue(_requestContainer.TryResolve(new TypedService(type), out instance), "unable to resolve in request");
+ Assert.IsTrue(_serviceContainer.TryResolveService(new TypedService(type), out instance), "unable to resolve in service");
+ Assert.IsTrue(_requestContainer.TryResolveService(new TypedService(type), out instance), "unable to resolve in request");
break;
case DreamContainerScope.Request:
Assert.AreEqual(InstanceSharing.Shared, registration.Sharing);
try {
- Assert.IsFalse(_hostContainer.TryResolve(new TypedService(type), out instance), "able to resolve in host");
+ Assert.IsFalse(_hostContainer.TryResolveService(new TypedService(type), out instance), "able to resolve in host");
} catch(DependencyResolutionException) {}
try {
- Assert.IsFalse(_serviceContainer.TryResolve(new TypedService(type), out instance), "able to resolve in service");
+ Assert.IsFalse(_serviceContainer.TryResolveService(new TypedService(type), out instance), "able to resolve in service");
} catch(DependencyResolutionException) {}
- Assert.IsTrue(_requestContainer.TryResolve(new TypedService(type), out instance), "unable to resolve in request");
+ Assert.IsTrue(_requestContainer.TryResolveService(new TypedService(type), out instance), "unable to resolve in request");
break;
}
}
@@ -168,7 +169,7 @@ public class XDocAutofacContainerConfiguratorTests {
private void IsRegisteredInScopeWithName(Type type, DreamContainerScope scope, string name) {
IComponentRegistration registration;
- Assert.IsTrue(_serviceContainer.ComponentRegistry.TryGetRegistration(new NamedService(name, type), out registration),
+ Assert.IsTrue(_serviceContainer.ComponentRegistry.TryGetRegistration(new KeyedService(name, type), out registration),
string.Format("no registration found for type '{0}' with name '{1}'", typeof(Foo), "fooz"));
Assert.AreEqual(InstanceOwnership.OwnedByLifetimeScope, registration.Ownership);
object instance;
@@ -178,27 +179,27 @@ public class XDocAutofacContainerConfiguratorTests {
break;
case DreamContainerScope.Host:
Assert.AreEqual(InstanceSharing.Shared, registration.Sharing);
- Assert.IsTrue(_hostContainer.TryResolve(name, type, out instance), "unable to resolve in host");
- Assert.IsTrue(_serviceContainer.TryResolve(name, type, out instance), "unable to resolve in service");
- Assert.IsTrue(_requestContainer.TryResolve(name, type, out instance), "unable to resolve in request");
+ Assert.IsTrue(_hostContainer.TryResolveNamed(name, type, out instance), "unable to resolve in host");
+ Assert.IsTrue(_serviceContainer.TryResolveNamed(name, type, out instance), "unable to resolve in service");
+ Assert.IsTrue(_requestContainer.TryResolveNamed(name, type, out instance), "unable to resolve in request");
break;
case DreamContainerScope.Service:
Assert.AreEqual(InstanceSharing.Shared, registration.Sharing);
try {
- Assert.IsFalse(_hostContainer.TryResolve(name, type, out instance), "able to resolve in host");
+ Assert.IsFalse(_hostContainer.TryResolveNamed(name, type, out instance), "able to resolve in host");
} catch(DependencyResolutionException) {}
- Assert.IsTrue(_serviceContainer.TryResolve(name, type, out instance), "unable to resolve in service");
- Assert.IsTrue(_requestContainer.TryResolve(name, type, out instance), "unable to resolve in request");
+ Assert.IsTrue(_serviceContainer.TryResolveNamed(name, type, out instance), "unable to resolve in service");
+ Assert.IsTrue(_requestContainer.TryResolveNamed(name, type, out instance), "unable to resolve in request");
break;
case DreamContainerScope.Request:
Assert.AreEqual(InstanceSharing.Shared, registration.Sharing);
try {
- Assert.IsFalse(_hostContainer.TryResolve(name, type, out instance), "able to resolve in host");
+ Assert.IsFalse(_hostContainer.TryResolveNamed(name, type, out instance), "able to resolve in host");
} catch(DependencyResolutionException) {}
try {
- Assert.IsFalse(_serviceContainer.TryResolve(name, type, out instance), "able to resolve in service");
+ Assert.IsFalse(_serviceContainer.TryResolveNamed(name, type, out instance), "able to resolve in service");
} catch(DependencyResolutionException) {}
- Assert.IsTrue(_requestContainer.TryResolve(name, type, out instance), "unable to resolve in request");
+ Assert.IsTrue(_requestContainer.TryResolveNamed(name, type, out instance), "unable to resolve in request");
break;
}
}
View
3  src/tests/Storage/AwsS3PrivateStorageTests.cs
@@ -21,6 +21,7 @@
using System;
using Autofac;
+using Autofac.Builder;
using log4net;
using MindTouch.Aws;
using MindTouch.Dream.Test;
@@ -66,7 +67,7 @@ public class AwsS3PrivateStorageTests {
_s3ClientMock = new Mock<IAwsS3Client>();
return _s3ClientMock.Object;
}).As<IAwsS3Client>().ServiceScoped();
- _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build());
+ _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build(ContainerBuildOptions.Default));
}
[SetUp]
View
3  src/tests/Storage/AwsS3PublicStorageTests.cs
@@ -21,6 +21,7 @@
using System;
using Autofac;
+using Autofac.Builder;
using log4net;
using MindTouch.Aws;
using MindTouch.Dream.Test;
@@ -68,7 +69,7 @@ public class AwsS3PublicStorageTests {
_clientProxy = new AwsS3ClientProxy();
return _clientProxy;
}).As<IAwsS3Client>().ServiceScoped();
- _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build());
+ _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build(ContainerBuildOptions.Default));
}
[SetUp]
View
3  src/tests/Storage/AwsS3StorageTest.cs
@@ -21,6 +21,7 @@
using System;
using Autofac;
+using Autofac.Builder;
using log4net;
using MindTouch.Aws;
using MindTouch.Dream.Test;
@@ -59,7 +60,7 @@ public class AwsS3StorageTest {
_s3ClientMock = mock;
return mock.Object;
}).As<IAwsS3Client>().ServiceScoped();
- _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build());
+ _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build(ContainerBuildOptions.Default));
}
[SetUp]
View
2  src/tests/test.mindtouch.core/Services/EmailServiceTests.cs
@@ -75,7 +75,7 @@ public class SmtplClientMock : ISmtpClient {
var builder = new ContainerBuilder();
_smtpClientFactory = new SmtpClientFactoryMock();
builder.Register(c => _smtpClientFactory).As<ISmtpClientFactory>().ServiceScoped();
- _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build());
+ _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build(ContainerBuildOptions.Default));
_emailService = DreamTestHelper.CreateService(
_hostInfo,
"sid://mindtouch.com/2009/01/dream/email",

No commit comments for this range

Something went wrong with that request. Please try again.