Example #1
0
        /// <summary>
        /// 依赖注入统一方法
        /// </summary>
        protected async virtual ValueTask DependencyInjection()
        {
            ConfigOptions  = ServiceProvider.GetService <IOptions <CoreOptions <MainGrain> > >().Value;
            StorageFactory = ServiceProvider.GetService <IStorageFactoryContainer>().CreateFactory(GrainType);
            Serializer     = ServiceProvider.GetService <ISerializer>();
            //创建事件存储器
            var eventStorageTask = StorageFactory.CreateEventStorage <PrimaryKey>(this, GrainId);

            if (!eventStorageTask.IsCompletedSuccessfully)
            {
                await eventStorageTask;
            }
            EventStorage = eventStorageTask.Result;
            //创建状态存储器
            var stateStorageTask = StorageFactory.CreateFollowSnapshotStorage <PrimaryKey>(this, GrainId);

            if (!stateStorageTask.IsCompletedSuccessfully)
            {
                await stateStorageTask;
            }
            FollowSnapshotStorage = stateStorageTask.Result;
        }