Esempio n. 1
0
 /// <summary>
 /// Gets a reference to a grain.
 /// </summary>
 /// <typeparam name="TGrainInterface">The interface to get.</typeparam>
 /// <param name="primaryKey">The primary key of the grain.</param>
 /// <param name="grainClassNamePrefix">An optional class name prefix used to find the runtime type of the grain.</param>
 /// <returns></returns>
 public TGrainInterface GetGrain <TGrainInterface>(long primaryKey, string grainClassNamePrefix = null) where TGrainInterface : IGrainWithIntegerKey
 {
     return(Cast <TGrainInterface>(
                GrainFactoryBase.MakeGrainReference_FromType(
                    baseTypeCode => TypeCodeMapper.ComposeGrainId(baseTypeCode, primaryKey, typeof(TGrainInterface)),
                    typeof(TGrainInterface),
                    grainClassNamePrefix)));
 }
Esempio n. 2
0
        /// <summary>
        /// Gets a reference to a grain.
        /// </summary>
        /// <typeparam name="TGrainInterface">The interface to get.</typeparam>
        /// <param name="primaryKey">The primary key of the grain.</param>
        /// <param name="grainClassNamePrefix">An optional class name prefix used to find the runtime type of the grain.</param>
        /// <returns>A reference to the specified grain.</returns>
        public TGrainInterface GetGrain <TGrainInterface>(long primaryKey, string grainClassNamePrefix = null) where TGrainInterface : IGrainWithIntegerKey
        {
            Type interfaceType  = typeof(TGrainInterface);
            var  implementation = this.GetGrainClassData(interfaceType, grainClassNamePrefix);
            var  grainId        = TypeCodeMapper.ComposeGrainId(implementation, primaryKey, interfaceType);

            return(this.Cast <TGrainInterface>(this.MakeGrainReferenceFromType(interfaceType, grainId)));
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a reference to a grain.
        /// </summary>
        /// <typeparam name="TGrainInterface">The interface to get.</typeparam>
        /// <param name="primaryKey">The primary key of the grain.</param>
        /// <param name="keyExtension">The key extention of the grain.</param>
        /// <param name="grainClassNamePrefix">An optional class name prefix used to find the runtime type of the grain.</param>
        /// <returns></returns>
        public TGrainInterface GetGrain <TGrainInterface>(long primaryKey, string keyExtension, string grainClassNamePrefix = null)
            where TGrainInterface : IGrainWithIntegerCompoundKey
        {
            GrainFactoryBase.DisallowNullOrWhiteSpaceKeyExtensions(keyExtension);

            return(Cast <TGrainInterface>(
                       GrainFactoryBase.MakeGrainReference_FromType(
                           baseTypeCode => TypeCodeMapper.ComposeGrainId(baseTypeCode, primaryKey, typeof(TGrainInterface), keyExtension),
                           typeof(TGrainInterface),
                           grainClassNamePrefix)));
        }
Esempio n. 4
0
 /// <summary>
 /// Fabricate a grain reference for a grain with the specified Guid primary key
 /// </summary>
 /// <param name="grainInterfaceType">Grain type</param>
 /// <param name="primaryKey">Primary key for the grain</param>
 /// <param name="grainClassNamePrefix">Prefix or full name of the grain class to disambiguate multiple implementations.</param>
 /// <returns><c>GrainReference</c> for connecting to the self-managed grain with the specified primary key</returns>
 /// <exception cref="System.ArgumentException">If called for a grain type that is not a valid grain type.</exception>
 public static IAddressable MakeGrainReferenceInternal(
     Type grainInterfaceType,
     string primaryKey,
     string grainClassNamePrefix = null)
 {
     return
         (MakeGrainReference_FromType(
              implementation => TypeCodeMapper.ComposeGrainId(implementation, primaryKey, grainInterfaceType),
              grainInterfaceType,
              grainClassNamePrefix));
 }
Esempio n. 5
0
        /// <summary>
        /// Gets a reference to a grain.
        /// </summary>
        /// <typeparam name="TGrainInterface">The interface to get.</typeparam>
        /// <param name="primaryKey">The primary key of the grain.</param>
        /// <param name="keyExtension">The key extention of the grain.</param>
        /// <param name="grainClassNamePrefix">An optional class name prefix used to find the runtime type of the grain.</param>
        /// <returns>A reference to the specified grain.</returns>
        public TGrainInterface GetGrain <TGrainInterface>(long primaryKey, string keyExtension, string grainClassNamePrefix = null)
            where TGrainInterface : IGrainWithIntegerCompoundKey
        {
            GrainFactoryBase.DisallowNullOrWhiteSpaceKeyExtensions(keyExtension);

            Type interfaceType  = typeof(TGrainInterface);
            var  implementation = this.GetGrainClassData(interfaceType, grainClassNamePrefix);
            var  grainId        = TypeCodeMapper.ComposeGrainId(implementation, primaryKey, interfaceType, keyExtension);

            return(this.Cast <TGrainInterface>(this.MakeGrainReferenceFromType(interfaceType, grainId)));
        }
Esempio n. 6
0
 /// <summary>
 /// Fabricate a grain reference for a grain with the specified Guid primary key
 /// </summary>
 /// <param name="grainInterfaceType">Grain type</param>
 /// <param name="interfaceId">Type code value for this self-managed grain type</param>
 /// <param name="primaryKey">Primary key for the grain</param>
 /// <param name="grainClassNamePrefix">Prefix or full name of the grain class to disambiguate multiple implementations.</param>
 /// <returns><c>GrainReference</c> for connecting to the self-managed grain with the specified primary key</returns>
 /// <exception cref="System.ArgumentException">If called for a grain type that is not a valid grain type.</exception>
 public static IAddressable MakeGrainReferenceInternal(
     Type grainInterfaceType,
     int interfaceId,
     string primaryKey,
     string grainClassNamePrefix = null)
 {
     return
         (MakeGrainReference(
              baseTypeCode => TypeCodeMapper.ComposeGrainId(baseTypeCode, primaryKey, grainInterfaceType),
              grainInterfaceType,
              interfaceId,
              grainClassNamePrefix));
 }
Esempio n. 7
0
        /// <summary>
        /// Fabricate a grain reference for an extended-key grain with the specified Int64 primary key
        /// </summary>
        /// <param name="grainInterfaceType">Grain type</param>
        /// <param name="primaryKey">Primary key for the grain</param>
        /// <param name="keyExt">Extended key for the grain</param>
        /// <param name="grainClassNamePrefix">Prefix or full name of the grain class to disambiguate multiple implementations.</param>
        /// <returns><c>GrainReference</c> for connecting to the grain with the specified primary key</returns>
        /// <exception cref="System.ArgumentException">If called for a grain type that is not a valid grain type.</exception>
        public static IAddressable MakeKeyExtendedGrainReferenceInternal(
            Type grainInterfaceType,
            long primaryKey,
            string keyExt,
            string grainClassNamePrefix = null)
        {
            DisallowNullOrWhiteSpaceKeyExtensions(keyExt);

            return
                (MakeGrainReference_FromType(
                     implementation => TypeCodeMapper.ComposeGrainId(implementation, primaryKey, grainInterfaceType, keyExt),
                     grainInterfaceType,
                     grainClassNamePrefix));
        }
Esempio n. 8
0
        /// <summary>
        /// Fabricate a grain reference for an extended-key grain with the specified Guid primary key
        /// </summary>
        /// <param name="grainInterfaceType">Grain type</param>
        /// <param name="interfaceId">Type code value for this grain type</param>
        /// <param name="primaryKey">Primary key for the grain</param>
        /// <param name="keyExt">Extended key for the grain</param>
        /// <param name="grainClassNamePrefix">Prefix or full name of the grain class to disambiguate multiple implementations.</param>
        /// <returns><c>GrainReference</c> for connecting to the grain with the specified primary key</returns>
        /// <exception cref="System.ArgumentException">If called for a grain type that is not a valid grain type.</exception>
        public static IAddressable MakeKeyExtendedGrainReferenceInternal(
            Type grainInterfaceType,
            int interfaceId,
            Guid primaryKey,
            string keyExt,
            string grainClassNamePrefix = null)
        {
            DisallowNullOrWhiteSpaceKeyExtensions(keyExt);

            return
                (MakeGrainReference(
                     baseTypeCode => TypeCodeMapper.ComposeGrainId(baseTypeCode, primaryKey, grainInterfaceType, keyExt),
                     grainInterfaceType,
                     interfaceId,
                     grainClassNamePrefix));
        }