/// <summary> /// Takes a processing node and determines if it extends other recursive nodes. If it does, then it calls the callback with the recursive node. /// </summary> /// <typeparam name="TResult">Type of the result of the processor</typeparam> /// <typeparam name="TSerializer">Type of the serializer</typeparam> /// <param name="processor">Processor</param> /// <param name="callbackName">Name of the method in the class, must be the same that calls it</param> public static void ProcessNode <TResult, TSerializer>( IProcessorNode <TResult, TSerializer> processor, string callbackName, params object[] args) where TSerializer : ISerializer { if (processor is ISimpleProcessorNode <TResult, TSerializer> ) { //We don't have to do anything with a simple processor return; } else { //We check if it's a recursive processor if (!InheritsFromRecursiveNode(processor.GetType())) { throw new ArgumentException(string.Format("The type '{0}' must be recursive", processor.GetType().Name), "processor"); } //We cast to the recursive node var recType = ObtainSuperClass(processor.GetType(), IsRecursiveNode); //We obtain the remaining list of processors var rest = recType.GetProperty("ProcessorStructure").GetValue(processor, null); //Gets the generic types Type r1Type = recType.GetGenericArguments()[1]; Type r2Type = recType.GetGenericArguments()[2]; //We apply recursion over the internal list of processors var methodArgs = new[] { rest }.Concat(args).ToArray(); typeof(ProcessorUtilities) .GetMethod(callbackName, BindingFlags.Public | BindingFlags.Static) .MakeGenericMethod(new[] { r1Type, r2Type }) .Invoke(null, methodArgs); } }
protected IProcessorStructure <TResult, TSerializer> CreateProcessorStructure <TResult>(IProcessorNode <TResult, TSerializer> processor) { return(new ProcessorStructure <TResult, TSerializer>(processor)); }
public void Add(IProcessorNode <TResult, TSerializer> item) { ProcessorList.Add(item); }
public void Insert(int index, IProcessorNode <TResult, TSerializer> item) { ProcessorList.Insert(index, item); }
public int IndexOf(IProcessorNode <TResult, TSerializer> item) { return(ProcessorList.IndexOf(item)); }
public bool Remove(IProcessorNode <TResult, TSerializer> item) { return(ProcessorList.Remove(item)); }
public bool Contains(IProcessorNode <TResult, TSerializer> item) { return(ProcessorList.Contains(item)); }