private static IGrainService GrainServiceFactory(Type serviceType, IServiceProvider services)
        {
            var grainServiceInterfaceType = serviceType.GetInterfaces().FirstOrDefault(x => x.GetInterfaces().Contains(typeof(IGrainService)));

            if (grainServiceInterfaceType == null)
            {
                throw new InvalidOperationException(String.Format($"Cannot find an interface on {serviceType.FullName} which implements IGrainService"));
            }
            var typeCode     = GrainInterfaceUtils.GetGrainClassTypeCode(grainServiceInterfaceType);
            var grainId      = (GrainId)LegacyGrainId.GetGrainServiceGrainId(0, typeCode);
            var grainService = (GrainService)ActivatorUtilities.CreateInstance(services, serviceType, grainId);

            return(grainService);
        }
コード例 #2
0
        private static GrainId GetGrainId()
        {
            var typeCode = GrainInterfaceUtils.GetGrainClassTypeCode(typeof(IReminderService));

            return(LegacyGrainId.GetGrainServiceGrainId(0, typeCode));
        }