forked from OrleansContrib/Orleankka
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutofacActorActivator.cs
More file actions
34 lines (27 loc) · 903 Bytes
/
AutofacActorActivator.cs
File metadata and controls
34 lines (27 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Linq;
using Orleankka;
using Orleankka.Core;
using Autofac;
namespace Example
{
public sealed class AutofacActorActivator : ActorActivator<Action<ContainerBuilder>>
{
IContainer container;
public override void Init(Action<ContainerBuilder> setup)
{
if (setup == null)
throw new ArgumentNullException(
"setup", "Expected setup action of type Action<ContainerBuilder>");
var builder = new ContainerBuilder();
setup(builder);
container = builder.Build();
}
public override Actor Activate(Type type, string id, IActorRuntime runtime)
{
return (Actor) container.Resolve(type,
new NamedParameter("id", id),
new TypedParameter(typeof(IActorRuntime), runtime));
}
}
}