Ejemplo n.º 1
0
        private static ImmutableDictionary <GrainType, GrainProperties> CreateGrainManifest(
            IEnumerable <IGrainPropertiesProvider> grainMetadataProviders,
            IOptions <GrainTypeOptions> grainTypeOptions,
            GrainTypeResolver grainTypeProvider)
        {
            var propertiesMap = ImmutableDictionary.CreateBuilder <GrainType, GrainProperties>();

            foreach (var grainClass in grainTypeOptions.Value.Classes)
            {
                var grainType  = grainTypeProvider.GetGrainType((Type)grainClass);
                var properties = new Dictionary <string, string>();
                foreach (var provider in grainMetadataProviders)
                {
                    provider.Populate((Type)grainClass, grainType, properties);
                }

                var result = new GrainProperties(properties.ToImmutableDictionary());
                if (propertiesMap.ContainsKey(grainType))
                {
                    throw new InvalidOperationException($"An entry with the key {grainType} is already present."
                                                        + $"\nExisting: {propertiesMap[grainType].ToDetailedString()}\nTrying to add: {result.ToDetailedString()}"
                                                        + "\nConsider using the [GrainType(\"name\")] attribute to give these classes unique names.");
                }

                propertiesMap.Add(grainType, result);
            }

            return(propertiesMap.ToImmutable());
        }
Ejemplo n.º 2
0
        public ClientManifestProvider(
            IEnumerable <IGrainPropertiesProvider> grainPropertiesProviders,
            IEnumerable <IGrainInterfacePropertiesProvider> grainInterfacePropertiesProviders,
            IOptions <GrainTypeOptions> grainTypeOptions,
            GrainTypeResolver grainTypeResolver,
            GrainInterfaceTypeResolver interfaceTypeResolver)
        {
            var grainProperties = CreateGrainManifest(grainPropertiesProviders, grainTypeOptions, grainTypeResolver);
            var interfaces      = CreateInterfaceManifest(grainInterfacePropertiesProviders, grainTypeOptions, interfaceTypeResolver);

            this.ClientManifest = new GrainManifest(grainProperties, interfaces);
        }
        public ClientManifestProvider(
            IEnumerable <IGrainPropertiesProvider> grainPropertiesProviders,
            IEnumerable <IGrainInterfacePropertiesProvider> grainInterfacePropertiesProviders,
            IApplicationPartManager applicationPartManager,
            GrainTypeResolver grainTypeResolver,
            GrainInterfaceTypeResolver interfaceTypeResolver)
        {
            var grainProperties = CreateGrainManifest(grainPropertiesProviders, applicationPartManager, grainTypeResolver);
            var interfaces      = CreateInterfaceManifest(grainInterfacePropertiesProviders, applicationPartManager, interfaceTypeResolver);

            this.ClientManifest = new GrainManifest(grainProperties, interfaces);
        }