void DoSequenceOrParallelOrAdd( IActivityMonitor monitor, Action<ActionConfiguration> collector, XElement xml ) { if( xml.Name == "Parallel" || xml.Name == "Sequence" ) { Action<ActionConfiguration> elementCollector; if( xml.Name == "Parallel" ) { var p = new ActionParallelConfiguration( xml.AttributeRequired( "Name" ).Value ); elementCollector = a => p.AddAction( a ); collector( p ); } else { var s = new ActionSequenceConfiguration( xml.AttributeRequired( "Name" ).Value ); elementCollector = a => s.AddAction( a ); collector( s ); } foreach( var action in xml.Elements() ) DoSequenceOrParallelOrAdd( monitor, collector, action ); } else { if( xml.Name != "Add" ) throw new XmlException( String.Format( "Unknown element '{0}': only <Add>, <Parallel> or <Sequence>.", xml.Name ) ); string type = xml.AttributeRequired( "Type" ).Value; Type t = FindConfigurationType( type ); HandlerConfiguration hC = (HandlerConfiguration)Activator.CreateInstance( t, xml.AttributeRequired( "Name" ).Value ); hC.DoInitialize( monitor, xml ); collector( hC ); } }
/// <summary> /// Must me implemented to create a sequence action. /// </summary> /// <param name="monitor">Monitor to use if needed.</param> /// <param name="configLock"> /// Configuration lock. It must not be solicited during the creation of the sequence: a sequence that delays /// its work can keep a reference to it and use it as needed. /// </param> /// <param name="c">Configuration of the sequence action.</param> /// <param name="children">Array of already created children action.</param> /// <returns>A sequence action.</returns> protected abstract TAction DoCreateSequence(IActivityMonitor monitor, IRouteConfigurationLock configLock, ActionSequenceConfiguration c, TAction[] children);
public SequenceHandler( ActionSequenceConfiguration c, HandlerBase[] children ) : base( c ) { _children = children; }