Ejemplo n.º 1
0
        private GrainClassData GetGrainClassData(Type interfaceType, string grainClassNamePrefix)
        {
            if (!GrainInterfaceUtils.IsGrainType(interfaceType))
            {
                throw new ArgumentException("Cannot fabricate grain-reference for non-grain type: " + interfaceType.FullName);
            }

            var            grainTypeResolver = this.runtimeClient.GrainTypeResolver;
            GrainClassData implementation;

            if (!grainTypeResolver.TryGetGrainClassData(interfaceType, out implementation, grainClassNamePrefix))
            {
                var loadedAssemblies = grainTypeResolver.GetLoadedGrainAssemblies();
                var assembliesString = string.IsNullOrEmpty(loadedAssemblies)
                    ? string.Empty
                    : " Loaded grain assemblies: " + loadedAssemblies;
                var grainClassPrefixString = string.IsNullOrEmpty(grainClassNamePrefix)
                    ? string.Empty
                    : ", grainClassNamePrefix: " + grainClassNamePrefix;
                throw new ArgumentException(
                          $"Cannot find an implementation class for grain interface: {interfaceType}{grainClassPrefixString}. " +
                          "Make sure the grain assembly was correctly deployed and loaded in the silo." + assembliesString);
            }

            return(implementation);
        }
Ejemplo n.º 2
0
        private GrainClassData GetGrainClassData(Type interfaceType, string grainClassNamePrefix)
        {
            if (!GrainInterfaceUtils.IsGrainType(interfaceType))
            {
                throw new ArgumentException("Cannot fabricate grain-reference for non-grain type: " + interfaceType.FullName);
            }

            var implementation = TypeCodeMapper.GetImplementation(this.runtimeClient.GrainTypeResolver, interfaceType, grainClassNamePrefix);

            return(implementation);
        }
Ejemplo n.º 3
0
        private long GetTypeCode(Type interfaceType, string grainClassNamePrefix = null)
        {
            if (!GrainInterfaceUtils.IsGrainType(interfaceType))
            {
                throw new ArgumentException("Cannot create grain-reference for non-grain type: " + interfaceType.FullName);
            }

            var found = this.runtimeClient.GrainTypeResolver.TryGetGrainClassData(interfaceType, out GrainClassData implementation, grainClassNamePrefix);

            if (!found)
            {
                var grainClassPrefixString = string.IsNullOrEmpty(grainClassNamePrefix)
                    ? string.Empty
                    : ", grainClassNamePrefix: " + grainClassNamePrefix;
                throw new ArgumentException(
                          $"Cannot find an implementation class for grain interface: {interfaceType} with implementation prefix: {grainClassPrefixString ?? "(none)"}. " +
                          "Make sure the grain assembly was correctly deployed and loaded in the silo.");
            }

            return(implementation.GetTypeCode(interfaceType));
        }