Beispiel #1
0
 public async Task StartAsync(NodeConfig nodeConfig, PatternActionsRegistry <M, P> registry = null)
 {
     if (nodeConfig.AssemblyLocations != null && nodeConfig.AssemblyLocations.Any())
     {
         InstallAssemblyResolver(nodeConfig.AssemblyLocations.Distinct());
     }
     await DoStartAsync(nodeConfig, registry);
 }
 public void AddRegistry(PatternActionsRegistry <M, P> registry)
 {
     if (registry != null)
     {
         Registry.AddRange(registry.Registry);
         registry.ProcessingUnitResourceFactories.ToList().ForEach(x => ProcessingUnitResourceFactories[x.Key] = x.Value);
     }
 }
        // Load actions from the assembly, looking for a method with attribute PatternActionsRegistration
        // Returns Code actions only
        public void AddFromAssembly(string assemblyName, Predicate <MessageRegistryEntry> filter = null)
        {
            var assembly            = Assembly.Load(assemblyName);
            var registrationMethods = assembly.GetTypes().SelectMany(type => type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod).Where(method => method.GetCustomAttributes <PatternActionsRegistrationAttribute>(false).Count() > 0));
            PatternActionsRegistry <M, P> registry = new PatternActionsRegistry <M, P>();

            foreach (var method in registrationMethods)
            {
                method.Invoke(null, new[] { registry });
            }
            if (filter == null)
            {
                AddRegistry(registry);
            }
            else
            {
                Registry.AddRange(registry.Registry.Where(entry => filter(entry)));
                registry.ProcessingUnitResourceFactories.ToList().ForEach(x => ProcessingUnitResourceFactories[x.Key] = x.Value);
            }
        }
Beispiel #4
0
 public void Start(NodeConfig nodeConfig, PatternActionsRegistry <M, P> registry = null)
 => StartAsync(nodeConfig, registry).Wait();
Beispiel #5
0
 protected abstract Task DoStartAsync(NodeConfig nodeConfig, PatternActionsRegistry <M, P> registry = null);