예제 #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);
 }
예제 #2
0
 public void AddRegistry(PatternActionsRegistry <M, P> registry)
 {
     if (registry != null)
     {
         Registry.AddRange(registry.Registry);
         registry.ProcessingUnitResourceFactories.ToList().ForEach(x => ProcessingUnitResourceFactories[x.Key] = x.Value);
     }
 }
예제 #3
0
        // 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);
            }
        }
예제 #4
0
 public void Start(NodeConfig nodeConfig, PatternActionsRegistry <M, P> registry = null)
 => StartAsync(nodeConfig, registry).Wait();
예제 #5
0
 protected abstract Task DoStartAsync(NodeConfig nodeConfig, PatternActionsRegistry <M, P> registry = null);