예제 #1
0
        private static ImmutableDictionary <GrainInterfaceId, GrainInterfaceProperties> CreateInterfaceManifest(
            IEnumerable <IGrainInterfacePropertiesProvider> propertyProviders,
            IApplicationPartManager applicationPartManager,
            GrainInterfaceIdResolver grainInterfaceIdProvider)
        {
            var feature = applicationPartManager.CreateAndPopulateFeature <GrainInterfaceFeature>();
            var builder = ImmutableDictionary.CreateBuilder <GrainInterfaceId, GrainInterfaceProperties>();

            foreach (var value in feature.Interfaces)
            {
                var interfaceId = grainInterfaceIdProvider.GetGrainInterfaceId(value.InterfaceType);
                var properties  = new Dictionary <string, string>();
                foreach (var provider in propertyProviders)
                {
                    provider.Populate(value.InterfaceType, interfaceId, properties);
                }

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

                builder.Add(interfaceId, result);
            }

            return(builder.ToImmutable());
        }
예제 #2
0
        public SiloManifestProvider(
            IEnumerable <IGrainPropertiesProvider> grainPropertiesProviders,
            IEnumerable <IGrainInterfacePropertiesProvider> grainInterfacePropertiesProviders,
            IApplicationPartManager applicationPartManager,
            GrainTypeResolver typeProvider,
            GrainInterfaceIdResolver interfaceIdProvider)
        {
            var grains     = CreateGrainManifest(grainPropertiesProviders, applicationPartManager, typeProvider);
            var interfaces = CreateInterfaceManifest(grainInterfacePropertiesProviders, applicationPartManager, interfaceIdProvider);

            this.SiloManifest = new SiloManifest(grains, interfaces);
        }
예제 #3
0
 public ImplementedInterfaceProvider(GrainInterfaceIdResolver interfaceIdProvider)
 {
     this.interfaceIdProvider = interfaceIdProvider;
 }