private static ImmutableDictionary <GrainInterfaceType, GrainInterfaceProperties> CreateInterfaceManifest( IEnumerable <IGrainInterfacePropertiesProvider> propertyProviders, IApplicationPartManager applicationPartManager, GrainInterfaceTypeResolver grainInterfaceIdProvider) { var feature = applicationPartManager.CreateAndPopulateFeature <GrainInterfaceFeature>(); var builder = ImmutableDictionary.CreateBuilder <GrainInterfaceType, GrainInterfaceProperties>(); foreach (var value in feature.Interfaces) { var interfaceType = grainInterfaceIdProvider.GetGrainInterfaceType(value.InterfaceType); var properties = new Dictionary <string, string>(); foreach (var provider in propertyProviders) { provider.Populate(value.InterfaceType, interfaceType, properties); } var result = new GrainInterfaceProperties(properties.ToImmutableDictionary()); if (builder.ContainsKey(interfaceType)) { throw new InvalidOperationException($"An entry with the key {interfaceType} is already present." + $"\nExisting: {builder[interfaceType].ToDetailedString()}\nTrying to add: {result.ToDetailedString()}" + "\nConsider using the [GrainInterfaceType(\"name\")] attribute to give these interfaces unique names."); } builder.Add(interfaceType, result); } return(builder.ToImmutable()); }
public SiloManifestProvider( IEnumerable <IGrainPropertiesProvider> grainPropertiesProviders, IEnumerable <IGrainInterfacePropertiesProvider> grainInterfacePropertiesProviders, IOptions <GrainTypeOptions> grainTypeOptions, GrainTypeResolver typeProvider, GrainInterfaceTypeResolver interfaceIdProvider, TypeConverter typeConverter) { var(grainProperties, grainTypes) = CreateGrainManifest(grainPropertiesProviders, grainTypeOptions, typeProvider); var interfaces = CreateInterfaceManifest(grainInterfacePropertiesProviders, grainTypeOptions, interfaceIdProvider); this.SiloManifest = new GrainManifest(grainProperties, interfaces); this.GrainTypeMap = new GrainClassMap(typeConverter, grainTypes); }
/// <summary> /// Initializes a new instance of the <see cref="ImplementedInterfaceProvider"/> class. /// </summary> /// <param name="interfaceTypeResolver">The interface type resolver.</param> public ImplementedInterfaceProvider(GrainInterfaceTypeResolver interfaceTypeResolver) { this.interfaceTypeResolver = interfaceTypeResolver; }