internal void RegisterCommandFeature(Type channelType, Type queryFeatureType, CommandFeature cf)
        {
            Known(channelType);

            var channeId = channelType.FullName;

            if (!_channelFeaturesCommand.ContainsKey(channeId))
            {
                _channelFeaturesCommand[channeId] = new Dictionary <string, CommandFeature>();
            }

            var features  = _channelFeaturesCommand[channeId];
            var featureId = queryFeatureType.FullName;

            if (!features.ContainsKey(featureId))
            {
                features[featureId] = cf;
            }
            else
            {
                throw new TectureException($"Command feature {queryFeatureType.Name} is already implemented for {channelType.Name}");
            }

            cf._aux = _auxilary.ForChannel(channelType);
            cf.CallOnRegister();
        }
Beispiel #2
0
        internal void LoadCommands(ApplicationManager applicationManager)
        {
            var commandFeature = new CommandFeature();

            applicationManager.CommandFeatureProvider.PopulateFeature(applicationManager.Assembiles, commandFeature);

            foreach (var type in commandFeature.Commands)
            {
                LoadCommands(type.AsType());
            }
        }
Beispiel #3
0
        private static void RegisterCommands(IServiceCollection services, ApplicationManager manager)
        {
            //Register command feature
            manager.CommandFeatureProvider = new CommandFeatureProvider();

            var commandFeature = new CommandFeature();

            manager.PopulateFeature(commandFeature);

            //register command classes in DI
            foreach (var command in commandFeature.Commands)
            {
                services.TryAddTransient(command.AsType());
            }
        }
Beispiel #4
0
        internal static IServiceCollection AddCommands(this IServiceCollection services,
                                                       List <string> commandAssemblyArry)
        {
            var assemblyPartManager = new AssemblyPartManager();

            services.AddSingleton(assemblyPartManager);
            if (!assemblyPartManager.FeatureProviders.OfType <CommandFeatureProvider>().Any())
            {
                assemblyPartManager.FeatureProviders.Add(new CommandFeatureProvider());
            }

            services.AddSingleton <ITypeActivatorCache, TypeActivatorCache>();
            services.TryAddSingleton <ICommandDescriptorCollectionProvider, CommandDescriptorCollectionProvider>();
            services.TryAddSingleton <ICommandDescriptorContainer, CommandDescriptorContainer>();
            services.TryAddTransient <ICommandActivator, DefaultCommandActivator>();

            var commandAssemblies = new List <Assembly>();

            if (commandAssemblyArry != null && commandAssemblyArry.Any())
            {
                var definedAssemblies = AssemblyUtil.GetAssembliesFromStrings(commandAssemblyArry.ToArray());

                if (definedAssemblies.Any())
                {
                    commandAssemblies.AddRange(definedAssemblies);
                }
            }

            if (!commandAssemblies.Any())
            {
                commandAssemblies.Add(Assembly.GetEntryAssembly());
            }

            foreach (var assembly in commandAssemblies)
            {
                assemblyPartManager.AssemblyParts.Add(new AssemblyPart(assembly));
            }

            var feature = new CommandFeature();

            assemblyPartManager.PopulateFeature(feature);
            foreach (var command in feature.Commands.Select(c => c.AsType()))
            {
                services.TryAddTransient(command, command);
            }

            return(services);
        }
 public void RegisterCommandFeature(Type commandFeatureType, CommandFeature feature)
 {
     _multiplexer.RegisterCommandFeature(_channelType, commandFeatureType, feature);
 }
 public void PopulateFeature(CommandFeature feature)
 {
     CommandFeatureProvider.PopulateFeature(Assembiles, feature);
 }