protected int BindActor(IActorRef actor, IEnumerable<BoundType> boundTypes, ActorBindingFlags bindingFlags = 0)
{
if (_closed)
return 0;
lock (_boundActorLock)
{
if (GetBoundActorId(actor) != 0)
return 0;
var actorId = ++_lastBoundActorId;
var boundActor = new BoundActor
{
Actor = actor,
IsChildActor = (Self.Path == actor.Path.Parent),
BindingFlags = bindingFlags,
Types = boundTypes.ToList(),
DerivedTypes = GetDerivedBoundTypes(boundTypes)
};
_boundActorMap[actorId] = boundActor;
_boundActorInverseMap[actor] = actorId;
Context.Watch(actor);
if (bindingFlags.HasFlag(ActorBindingFlags.OpenThenNotification))
{
actor.Tell(new NotificationMessage
{
InvokePayload = new IActorBoundChannelObserver_PayloadTable.ChannelOpen_Invoke
{
channel = Self.Cast<ActorBoundChannelRef>(),
tag = _tag
},
});
}
return actorId;
}
}