public static void InjectCustomPipeline() { var pipelineDefs = (Dictionary<string, PipelineDefinition>)typeof(PipelineManager).InvokeMember("Definitions", BindingFlags.GetField | BindingFlags.Static | BindingFlags.NonPublic, Type.DefaultBinder, null, null); if (pipelineDefs == null) { return; } var procDefToInject = new SingleProcessorDefinition(); procDefToInject.Type = typeof(InstallFilesCleanup); procDefToInject.Title = "Performing cleanup"; PipelineDefinition installPipeline = pipelineDefs["install"]; foreach (StepDefinition step in installPipeline.Steps) { foreach (ProcessorDefinition procDef in step.ProcessorDefinitions) { if (procDef.Type == typeof(Extract)) { procDef.NestedProcessorDefinitions.Add(procDefToInject); return; } } } }
private static ProcessorDefinition ParseProcessorDefinition([NotNull] XmlElement processorElement) { Assert.ArgumentNotNull(processorElement, nameof(processorElement)); var typeNameValue = processorElement.GetAttribute("type"); var paramValue = processorElement.GetAttribute("param"); var titleValue = processorElement.GetAttribute("title"); var process = processorElement.GetAttribute("process"); try { Type type = Type.GetType(typeNameValue); Assert.IsNotNull(type, "Can't find the '{0}' type".FormatWith(typeNameValue)); ProcessorDefinition definition; var name = processorElement.Name; if (name.EqualsIgnoreCase("processor")) { definition = new SingleProcessorDefinition(); } // Support for dynamic processors (e.g. processors are created dynamically) else { Assert.IsTrue(name.EqualsIgnoreCase("hive"), "The {0} element is not supported".FormatWith(name)); definition = new MultipleProcessorDefinition(); } definition.Type = type; definition.Param = paramValue; definition.ProcessAlways = process.EqualsIgnoreCase("always"); definition.Title = titleValue; return(definition); } catch (Exception ex) { throw new InvalidOperationException("Can't instantiate processor definition: {0}".FormatWith(typeNameValue), ex); } }
private static ProcessorDefinition ParseProcessorDefinition([NotNull] XmlElement processorElement) { Assert.ArgumentNotNull(processorElement, "processorElement"); string typeNameValue = processorElement.GetAttribute("type"); string paramValue = processorElement.GetAttribute("param"); string titleValue = processorElement.GetAttribute("title"); string process = processorElement.GetAttribute("process"); try { Type type = Type.GetType(typeNameValue); Assert.IsNotNull(type, "Can't find the '{0}' type".FormatWith(typeNameValue)); ProcessorDefinition definition; var name = processorElement.Name; if (name.EqualsIgnoreCase("processor")) { definition = new SingleProcessorDefinition(); } // Support for dynamic processors (e.g. processors are created dynamically) else { Assert.IsTrue(name.EqualsIgnoreCase("hive"), "The {0} element is not supported".FormatWith(name)); definition = new MultipleProcessorDefinition(); } definition.Type = type; definition.Param = paramValue; definition.ProcessAlways = process.EqualsIgnoreCase("always"); definition.Title = titleValue; return definition; } catch (Exception ex) { throw new InvalidOperationException("Can't instantiate processor definition: {0}".FormatWith(typeNameValue), ex); } }