internal void AddPostprocessor(IPostProcessor instance) { if (!Postprocessors.Any(ipp => ipp.GetType() == instance.GetType())) { Postprocessors.Add(instance); } }
static void ValidatePostprocessor <T>(IPostProcessor instance) { if (Postprocessors.Any(p => p.GetType() == typeof(T))) { throw new InvalidOperationException(string.Format("Can't add multiple postprocessors of type: {0}", typeof(T).FullName)); } }
/// <summary> /// Initializes the class with the given <paramref name="container"/> instance. /// </summary> /// <param name="container">The target service container.</param> /// <param name="creator">The <see cref="ICreateInstance"/> instance responsible for instantiating service types.</param> /// <param name="preProcessor">The <see cref="IPreProcessor"/> that will allow users to intercept a given service request.</param> /// <param name="postProcessor">The <see cref="IPostProcessor"/> instance that will handle the results of a given service request.</param> public DefaultGetServiceBehavior(IServiceContainer container, ICreateInstance creator, IPreProcessor preProcessor, IPostProcessor postProcessor) { _container = container; _creator = creator; _preProcessor = preProcessor; _postProcessor = postProcessor; }
public CommentController(IPostProcessor postProcessor, IHttpContextAccessor httpContextAccessor, ICommentProcessor commentProcessor) { _postProcessor = postProcessor; _httpContextAccessor = httpContextAccessor; _commentProcessor = commentProcessor; }
public static IUndupAction CreateAction(ImportEngine engine, IPostProcessor processor, XmlNode node) { String type = node.ReadStr("@type"); if ("add".Equals(type, StringComparison.OrdinalIgnoreCase)) { return(new UndupNumericAddAction(processor, node)); } if ("max".Equals(type, StringComparison.OrdinalIgnoreCase)) { return(new UndupNumericMaxAction(processor, node)); } if ("min".Equals(type, StringComparison.OrdinalIgnoreCase)) { return(new UndupNumericMinAction(processor, node)); } if ("mean".Equals(type, StringComparison.OrdinalIgnoreCase)) { return(new UndupNumericMeanAction(processor, node)); } if ("count".Equals(type, StringComparison.OrdinalIgnoreCase)) { return(new UndupCountAction(processor, node)); } if ("script".Equals(type, StringComparison.OrdinalIgnoreCase)) { return(new UndupScriptAction(engine, processor, node)); } throw new BMException("Unrecognized type [{0}] for a post process action.", type); //TODO make this more generic }
/// <summary> /// Initializes the class with the given <paramref name="container"/> instance. /// </summary> /// <param name="container">The target service container.</param> public DefaultGetServiceBehavior(IServiceContainer container) { _container = container; _creator = new DefaultCreator(); _preProcessor = new CompositePreProcessor(container.PreProcessors); _postProcessor = new CompositePostProcessor(container.PostProcessors); }
public ProcessAttribute(bool authorize = false) { this.Authorize = authorize; Type preProcessorType = typeof(TracePreProcessor); this.p1 = Activator.CreateInstance(preProcessorType) as IPreProcessor; if (this.p1 == null) { throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPreProcessor", preProcessorType.Name, "processorType")); } Type postProcessorType = typeof(TracePostProcessor); this.p2 = Activator.CreateInstance(postProcessorType) as IPostProcessor; if (this.p2 == null) { throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPostProcessor", postProcessorType.Name, "postProcessorType")); } Type exceptionProcessorType = typeof(TraceExceptionProcessor); this.p3 = Activator.CreateInstance(exceptionProcessorType) as IPostProcessor; if (this.p3 == null) { throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPostProcessor", exceptionProcessorType.Name, "exceptionProcessorType")); } if (Dependency.DependencyContainer.ServiceAuthorization != null) { this.p1.AddAuthorization(Dependency.DependencyContainer.ServiceAuthorization); } }
/// <summary>Puts a collection of given items through the postprocessor.</summary> /// <typeparam name="T">The type of object to process.</typeparam> /// <param name="Processor">The processor to use.</param> /// <param name="Items">The items to process.</param> /// <returns>Puts a collection of given items through the processor.</returns> public static void Postprocess <T>(this IPostProcessor <T> Processor, IEnumerable <T> Items) { foreach (T Item in Items) { Processor.Postprocess(Item); } }
public PostProcessorBase(PostProcessorBase other, IDataEndpoint epOrnextProcessor) { this.name = other.name; this.nextEndpoint = epOrnextProcessor; this.nextProcessor = epOrnextProcessor as IPostProcessor; instanceNo = ++other.instanceNo; }
// == CONSTRUCTORS ================================================================ public PostponedProcess(IPostProcessor inProcessor, string inName, object inData, int inStep) { Name = inName; Processor = inProcessor; Data = inData; Step = inStep; }
/// <summary> /// Prepare a process to be executed after all the other ones, keeping track of a method name and a Data to be used as arguments (Could use Invoke for that ?) /// </summary> /// <param name="Processor">The instance implementing IPostProcessor that will be called back </param> /// <param name="Name">Name of the process</param> /// <param name="Data">Data to be used as arguments</param> /// <param name="Step">The level of the process, it will be inserted just before other processes that have a higher step</param> public void PostponeProcess(IPostProcessor Processor, string Name, object Data, int Step) { foreach (PostponedProcess proc in _postPonedProcesses) { if (proc.Name == Name) { return; } } int index = 0; PostponedProcess newProc = new PostponedProcess(Processor, Name, Data, Step); foreach (PostponedProcess proc in _postPonedProcesses) { if (proc.Step > Step) { _postPonedProcesses.Insert(index, newProc); return; } index++; } _postPonedProcesses.Add(newProc); }
public UndupScriptAction(ImportEngine engine, IPostProcessor processor, XmlNode node) { originalNode = node; ScriptName = node.ReadStr("@script", null); ScriptBody = node.ReadStr(null, null); if (ScriptBody == null) { if (ScriptName == null) { throw new BMNodeException(node, "@script should be specified if there is no script in the body."); } } else { ScriptBody = ScriptBody.TrimWhiteSpaceToNull(); if (ScriptBody != null && ScriptName != null) { throw new BMNodeException(node, "Cannot have a script in the body when @script is specified."); } var scriptHolder = engine.ScriptExpressions; bodyFunc = ScriptExpressionHolder.GenerateScriptName("postprocessor_undup", processor.Name, node); scriptHolder.AddUndupExpression(bodyFunc, ScriptBody); } }
/// <summary>Puts a collection of given items through the postprocessor.</summary> /// <typeparam name="T">The type of object to process.</typeparam> /// <typeparam name="TypeContext">The type of the context.</typeparam> /// <param name="Processor">The processor to use.</param> /// <param name="Items">The items to process.</param> /// <param name="Context">The context needed to process.</param> public static void Postprocess <T, TypeContext>(this IPostProcessor <T, TypeContext> Processor, IEnumerable <T> Items, TypeContext Context) { foreach (T Item in Items) { Processor.Postprocess(Item, Context); } }
public PostController(ILogger <HomeController> logger, IPostProcessor postProcessor, ICategoryProcessor categoryProcessor, ICommentProcessor commentProcessor) { _logger = logger; _postProcessor = postProcessor; _categoryProcessor = categoryProcessor; _commentProcessor = commentProcessor; }
public PostProcessAttribute(Type postProcessorType) { this.p = Activator.CreateInstance(postProcessorType) as IPostProcessor; if (this.p == null) { throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPostProcessor", postProcessorType.Name, "processorType")); } }
/// <summary>Puts a collection of given items through the postprocessor.</summary> /// <typeparam name="T">The type of object to process.</typeparam> /// <param name="Processor">The processor to use.</param> /// <param name="Items">The items to process.</param> /// <returns>Puts a collection of given items through the processor.</returns> public static void Postprocess <T>(this IPostProcessor <T> Processor, T[] Items) { Int32 Count = Items.Length; for (Int32 I = 0; I < Count; I++) { Processor.Postprocess(Items[I]); } }
/// <summary>Puts a collection of given items through the postprocessor.</summary> /// <typeparam name="T">The type of object to process.</typeparam> /// <param name="Processor">The processor to use.</param> /// <param name="Items">The items to process.</param> /// <returns>Puts a collection of given items through the processor.</returns> public static void Postprocess <T>(this IPostProcessor <T> Processor, IList <T> Items) { Int32 Count = Items.Count; for (Int32 I = 0; I < Count; I++) { Processor.Postprocess(Items[I]); } }
/// <summary>Puts a collection of given items through the postprocessor.</summary> /// <typeparam name="T">The type of object to process.</typeparam> /// <typeparam name="TypeContext">The type of the context.</typeparam> /// <param name="Processor">The processor to use.</param> /// <param name="Items">The items to process.</param> /// <param name="Context">The context needed to process.</param> public static void Postprocess <T, TypeContext>(this IPostProcessor <T, TypeContext> Processor, IList <T> Items, TypeContext Context) { Int32 Count = Items.Count; for (Int32 I = 0; I < Count; I++) { Processor.Postprocess(Items[I], Context); } }
//private ImportEngine engine; //private SortProcessor sortProcessor; //private XmlNode actionsNode; public UndupActions(ImportEngine engine, IPostProcessor processor, XmlNode node) { XmlNodeList nodes = node.SelectNodes("action"); actions = new List <IUndupAction>(nodes.Count); foreach (XmlNode child in nodes) { actions.Add(CreateAction(engine, processor, child)); } }
public UndupNumericNumericAction(IPostProcessor processor, XmlNode node) { numberMode = node.ReadEnum("@number", NumberMode.Int); String from = node.ReadStr("field"); fromField = new JPath(from); String to = node.ReadStr("tofield", null); toField = to == null ? fromField : new JPath(to); }
public RecordActions(IPostProcessor processor, XmlNode node) { XmlNodeList nodes = node.SelectNodes("action"); actions = new List <IRecordAction>(nodes.Count); foreach (XmlNode child in nodes) { actions.Add(CreateAction(processor, child)); } }
/// <summary>Gets a list of default postprocessor instances</summary> /// <returns>List of default postprocessor instances</returns> public IList <IPostProcessor> GetDefaultPostProcessorInstances() { List <IPostProcessor> postProcessorList = new List <IPostProcessor>(); foreach (string postProcessorName in Utils.ConvertToStringCollection(this._assetConfig.DefaultPostProcessors, ',', true, true)) { IPostProcessor processorInstance = this.GetPostProcessorInstance(postProcessorName); postProcessorList.Add(processorInstance); } return((IList <IPostProcessor>)postProcessorList); }
public static IRecordAction CreateAction(IPostProcessor processor, XmlNode node) { String type = node.ReadStr("@type"); if ("add".Equals(type, StringComparison.OrdinalIgnoreCase)) { return(new RecordPruneAction(processor, node)); } throw new BMException("Unrecognized type [{0}] for a post process record-action.", type); //TODO make this more generic }
public NetworkTopology() { hiddenLayers = null; inputLayer = null; outputLayer = null; preProcessor = null; postProcessor = null; TrainingPreProcessor = null; TrainingAlgorithm = null; }
public const int REGEX = 1; // regex replaces public static string PostProcess(string text, string langCode) { try { IPostProcessor processor = ProcessorFactory.createProcessor((ISO639)Enum.Parse(typeof(ISO639), langCode.Substring(0, 3))); return(processor.PostProcess(text)); } catch { return(text); } }
/// <summary> /// This method is used to update the enabled state of a post processor registered to this PostProcessorManager. /// It will raise an exception if the post processor cannot be safely updated (e.g. it's mandatory). /// </summary> /// <param name="pp"></param> /// <param name="enableState"></param> /// <returns></returns> /// <exception cref="InvalidOperationException">Thrown when the post processor does not belong to this manager or is mandatory</exception> public void SetPostProcessorEnableState(IPostProcessor pp, bool enableState) { if (!PostProcessors.Contains(pp)) { throw new InvalidOperationException($"Post Processor {pp} does not belong to this manager"); } if (pp.Mandatory) { throw new InvalidOperationException("Unable to change the enabled state of a mandatory post processor"); } pp.Enabled = enableState; }
/// <summary> /// Adds a post-processor instance to the server /// </summary> /// <returns>The server configuration.</returns> /// <param name="postprocessor">The post-processor to add.</param> public ServerConfig AddPostProcessor(IPostProcessor postprocessor) { if (postprocessor == null) { throw new ArgumentNullException(nameof(postprocessor)); } if (PostProcessors == null) { PostProcessors = new List <IPostProcessor>(); } PostProcessors.Add(postprocessor); return(this); }
public UndupNumericMinAction(IPostProcessor processor, XmlNode node) : base(processor, node) { defMinLong = long.MaxValue; defMinDouble = double.MaxValue; if (numberMode == UndupNumericNumericAction.NumberMode.Int) { defMinLong = node.ReadInt64("@default", defMinLong); } else { defMinDouble = node.ReadFloat("@default", defMinDouble); } }
/// <summary> /// Gets a list of default postprocessor instances /// </summary> /// <returns>List of default postprocessor instances</returns> public IList <IPostProcessor> GetDefaultPostProcessorInstances() { var defaultPostProcessors = new List <IPostProcessor>(); string[] defaultPostProcessorNames = Utils.ConvertToStringCollection( _assetConfig.DefaultPostProcessors, ',', trimItemValues: true, removeEmptyItems: true); foreach (string defaultPostProcessorName in defaultPostProcessorNames) { IPostProcessor defaultPostProcessor = GetPostProcessorInstance(defaultPostProcessorName); defaultPostProcessors.Add(defaultPostProcessor); } return(defaultPostProcessors); }
public PostProcessors(ImportEngine engine, XmlNode collNode) { postProcessors = new StringDict <IPostProcessor>(); if (collNode == null) { return; } var nodes = collNode.SelectNodes("postprocessor"); for (int i = 0; i < nodes.Count; i++) { XmlNode c = nodes[i]; IPostProcessor p = ImportEngine.CreateObject <IPostProcessor> (c, engine, c); postProcessors.Add(p.Name, p); } }
/// <summary> /// Constructor /// </summary> /// <param name="applicationId">Application id this instance runs under.</param> /// <param name="processor">A IPostProcessor instance to write to.</param> /// <param name="samplingRate">An optional rate to sample with.</param> public TokenService(int applicationId, IPostProcessor<ITokenPairRecord> processor, double samplingRate = SamplingDisabled) { _applicationId = applicationId; _processor = processor; _samplingRate = samplingRate; Enabled = false; }
public ProcessAttribute(Type processorType) { this.postProcessor = Activator.CreateInstance(processorType) as IPostProcessor; if (this.postProcessor == null) throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPostProcessor", processorType.Name, "processorType")); this.preProcesser = Activator.CreateInstance(processorType) as IPreProcessor; if (this.preProcesser == null) throw new ArgumentException(String.Format("The type '{0}' does not implement interface IPreProcessor", processorType.Name, "processorType")); }