I got this to work to the extent that I need it to at this point. My JobGroup class is a TaskContainer, each Job is a Task. The collection of sub-Groups in each Group is an array of type JobGroup -- if I used a typed collection of JobGroups I got a reflection error (non-static method must have a target called in Element.IntializeCollections() ). I am using typed collections generated by a free tool I downloaded, maybe they don't implement all the methods they should.

I think that only the top level Group task is getting executed, I am not sure why. But as long as the tree is getting built during calls to Element.Initialize, I am ok with it. Thanks for your help.


Troy Laurin wrote:

On 9/25/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
[BuildElementArray("jobgroup")]
public JobGroupCollection groups
       {
           get { return _groups; }
           set
           {
               for( int i = 0; i < value.Count; i++ )
               {
                   JobGroup group = value[i];
                   this.addJobGroup( group );
               }
               this._groups = value;
           }
       }

[BuildElementArray("job")]
       public JobDefinitionCollection jobs
       {
           get { return _jobs; }
           set
           {
               String thisMethod = "jobs.set";
               log.Debug(thisMethod + ":entering...");
               for( int i = 0; i < value.Count; i++ )
               {
                   JobDefinition job = value[i];
                   this.addJobDefinition( job );
               }
               _jobs = value;
           }
       }
}

I notice that in your setter methods, you are calling a function to
individually add the job[group]s to your group, as well as setting the
passed job[group] into your local member.  Without seeting your
addJobGroup and addJobDefinition methods, I can't be sure, but it
looks like you're duplicating effort - you are likely to need only one
or the other.

But that shouldn't be causing the problem you describe...  Perhaps if
you add more logging (as the log.Debug line to specify that the jobs
setter is being accessed) and run ant with debug output enabled you
may have more insight why your nested jobs aren't being processed.


For a concrete example of a recursive datatype, look at the PathSet
datatype (NAnt.Core\Types\PathSet.cs)... the relevant snippet:
       /// <summary>
       /// Defines a set of path elements to add to the current path.
       /// </summary>
       /// <param name="path">The <see cref="PathSet" /> to add.</param>
       [BuildElement("path")]
       public void AddPath(PathSet path) {
           _elements.Add(path);
       }

       /// <summary>
       /// Defines a path element to add to the current path.
       /// </summary>
       /// <param name="pathElement">The <see cref="PathElement" />
to add.</param>
       [BuildElement("pathelement")]
       public void AddPathElement(PathElement pathElement) {
           _elements.Add(pathElement);
       }

The major difference (I believe) between using a property setter and
the AddXxx methods is that the AddXxx methods retain order,
particularly when the types are polymorphic and mixed, as in a path
element.


Hope that gives you something to work with,

Regards and good luck,


--
Troy


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
nant-developers mailing list
nant-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-developers



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
nant-developers mailing list
nant-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to