コード例 #1
0
        public DataActor(IDataRefsMutable dataRefsMutable)
        {
            DataRefsMutable = dataRefsMutable;

            // set data actor references
            dataRefsMutable.Data           = Context.Self;
            dataRefsMutable.Entities       = Context.ActorOf(Props.Create(() => new EntitiesActor()), EntitiesActor.GetName());
            dataRefsMutable.DataTypes      = Context.ActorOf(Props.Create(() => new DataTypesActor(dataRefsMutable.Entities)), DataTypesActor.GetName());
            dataRefsMutable.DataRows       = Context.ActorOf(Props.Create(() => new DataRowsActor(dataRefsMutable.Entities)), DataRowsActor.GetName());
            dataRefsMutable.DataRelations  = Context.ActorOf(Props.Create(() => new DataRelationsActor(dataRefsMutable.Entities)), DataRelationsActor.GetName());
            dataRefsMutable.DataReferences = Context.ActorOf(Props.Create(() => new DataReferencesActor(dataRefsMutable.Entities)), DataReferencesActor.GetName());
            dataRefsMutable.Orgs           = Context.ActorOf(Props.Create(() => new OrgsActor(dataRefsMutable.Entities)), OrgsActor.GetName());
            dataRefsMutable.Spaces         = Context.ActorOf(Props.Create(() => new SpacesActor(dataRefsMutable.Entities)), SpacesActor.GetName());
        }
コード例 #2
0
ファイル: AkkaEnvExtensions.cs プロジェクト: mattbragaw/mqb
        public static AkkaDataEnv WithDataActors(this AkkaEnv akkaEnv, IServiceProvider serviceProvider, Type actorRefsType)
        {
            if (actorRefsType.GetInterface(typeof(IDataRefs).Name) == null)
            {
                throw new ArgumentException("Type doesn't implement IDataRefs interface.");
            }
            if (actorRefsType.GetInterface(typeof(IDataRefsMutable).Name) == null)
            {
                throw new ArgumentException("Type doesn't implement IDataRefs interface.");
            }

            // get reference to dataRefs
            IDataRefsMutable dataRefs = (IDataRefsMutable)serviceProvider.GetRequiredService(actorRefsType);

            // data actor populates refs
            akkaEnv.ActorSystem.ActorOf(Props.Create(() => new DataActor(dataRefs)), EntitiesActor.GetName());

            // return actor system reference
            return(new AkkaDataEnv(akkaEnv.ActorSystem, dataRefs));
        }