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      = (IGrainIdentity)GrainId.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(GrainId.GetGrainServiceGrainId(0, typeCode));
        }