Exemple #1
0
        public IdentityActor(IIdentityRefsMutable identityRefsMutable)
        {
            EntitiesActor = identityRefsMutable.Entities;

            Receive <GetUsersRef>(cmd => Sender.Tell(new UsersRef(Users)));
            Receive <GetRolesRef>(cmd => Sender.Tell(new RolesRef(Roles)));

            Users = Context.ActorOf(Props.Create(() => new UserStoreActor(EntitiesActor)), ConstantsIdentity.USER_STORE);
            Roles = Context.ActorOf(Props.Create(() => new RoleStoreActor(EntitiesActor)), ConstantsIdentity.ROLE_STORE);

            Users.Tell(new RolesRef(Roles));
            Roles.Tell(new UsersRef(Users));

            identityRefsMutable.Identity      = Context.Self;
            identityRefsMutable.IdentityUsers = Users;
            identityRefsMutable.IdentityRoles = Roles;
        }
Exemple #2
0
        public static AkkaIdentityEnv WithIdentity(this AkkaDataEnv akkaDataEnv)
        {
            if (akkaDataEnv.DataRefs is IIdentityRefs == false)
            {
                throw new ArgumentException("Type doesn't implement IIdentityRefs interface.");
            }
            if (akkaDataEnv.DataRefs is IIdentityRefsMutable == false)
            {
                throw new ArgumentException("Type doesn't implement IIdentityRefsMutable interface.");
            }

            // get reference to identityRefs
            IIdentityRefsMutable identityRefs = (IIdentityRefsMutable)akkaDataEnv.DataRefs;

            // identity actor populates refs
            akkaDataEnv.ActorSystem.ActorOf(Props.Create(() => new IdentityActor(identityRefs)), IdentityActor.GetName());

            // return actor system reference
            return(new AkkaIdentityEnv(akkaDataEnv.ActorSystem, identityRefs));
        }