Esempio 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 implementation = TypeCodeMapper.GetImplementation(this.runtimeClient.GrainTypeResolver, interfaceType, grainClassNamePrefix);

            return(implementation);
        }
Esempio n. 2
0
        internal static IAddressable MakeGrainReference_FromType(
            Func <GrainClassData, GrainId> getGrainId,
            Type interfaceType,
            string grainClassNamePrefix = null)
        {
            CheckRuntimeEnvironmentSetup();
            if (!GrainInterfaceData.IsGrainType(interfaceType))
            {
                throw new ArgumentException("Cannot fabricate grain-reference for non-grain type: " + interfaceType.FullName);
            }
            var     implementation = TypeCodeMapper.GetImplementation(interfaceType, grainClassNamePrefix);
            GrainId grainId        = getGrainId(implementation);

            return(GrainReference.FromGrainId(grainId, interfaceType.IsGenericType ? interfaceType.UnderlyingSystemType.FullName : null));
        }
Esempio n. 3
0
        private static GrainId ConstructGrainId(string[] args, string operation)
        {
            if (args == null || args.Length < 2)
            {
                PrintUsage();
                return(null);
            }
            string interfaceTypeCodeOrImplClassName = args[0];
            int    interfaceTypeCodeDataLong;
            long   implementationTypeCode;

            if (Int32.TryParse(interfaceTypeCodeOrImplClassName, out interfaceTypeCodeDataLong))
            {
                // parsed it as int, so it is an interface type code.
                implementationTypeCode = TypeCodeMapper.GetImplementation(interfaceTypeCodeDataLong).GrainTypeCode;
            }
            else
            {
                // interfaceTypeCodeOrImplClassName is the implementation class name
                implementationTypeCode = TypeCodeMapper.GetImplementation(interfaceTypeCodeOrImplClassName).GrainTypeCode;
            }

            var     grainIdStr = args[1];
            GrainId grainId    = null;
            long    grainIdLong;
            Guid    grainIdGuid;

            if (Int64.TryParse(grainIdStr, out grainIdLong))
            {
                grainId = GrainId.GetGrainId(implementationTypeCode, grainIdLong);
            }
            else if (Guid.TryParse(grainIdStr, out grainIdGuid))
            {
                grainId = GrainId.GetGrainId(implementationTypeCode, grainIdGuid);
            }

            WriteStatus(string.Format("**Full Grain Id to {0} is: GrainId = {1}", operation, grainId.ToFullString()));
            return(grainId);
        }