@@ -626,7 +626,7 @@ public XmlDocument Save() {
626626 /// <exception cref="Confuser.Core.Project.ProjectValidationException">
627627 /// The project XML contains schema errors.
628628 /// </exception>
629- public void Load ( XmlDocument doc ) {
629+ public void Load ( XmlDocument doc , string baseDirRoot = null ) {
630630 doc . Schemas . Add ( Schema ) ;
631631 var exceptions = new List < XmlSchemaException > ( ) ;
632632 doc . Validate ( ( sender , e ) => {
@@ -641,7 +641,11 @@ public void Load(XmlDocument doc) {
641641
642642 OutputDirectory = docElem . Attributes [ "outputDir" ] . Value ;
643643 BaseDirectory = docElem . Attributes [ "baseDir" ] . Value ;
644-
644+ if ( ! string . IsNullOrEmpty ( baseDirRoot ) )
645+ {
646+ BaseDirectory = Path . Combine ( baseDirRoot , BaseDirectory ) ;
647+ }
648+
645649 if ( docElem . Attributes [ "seed" ] != null )
646650 Seed = docElem . Attributes [ "seed" ] . Value . NullIfEmpty ( ) ;
647651 else
@@ -674,13 +678,45 @@ public void Load(XmlDocument doc) {
674678 PluginPaths . Add ( i . InnerText ) ;
675679 }
676680 else {
677- var asm = new ProjectModule ( ) ;
678- asm . Load ( i ) ;
679- Add ( asm ) ;
681+ AddModule ( i ) ;
680682 }
681683 }
682684 }
683685
686+ internal void AddModule ( XmlElement elem ) {
687+ if ( IsWildcard ( elem . Attributes [ "path" ] . Value ) ) {
688+ BatchLoadModules ( elem ) ;
689+ }
690+ else {
691+ var asm = new ProjectModule ( ) ;
692+ asm . Load ( elem ) ;
693+ Add ( asm ) ;
694+ }
695+ }
696+
697+ internal bool IsWildcard ( string path ) {
698+ return ! string . IsNullOrEmpty ( path ) && path . Contains ( @"*" ) ;
699+ }
700+
701+ internal bool BatchLoadModules ( XmlElement elem ) {
702+ string wildCardPath = elem . Attributes [ "path" ] . Value ;
703+ string [ ] files = Directory . GetFiles ( BaseDirectory , wildCardPath , SearchOption . AllDirectories ) ; // TODO: recursive
704+ if ( files . Length <= 0 )
705+ {
706+ return false ;
707+ }
708+
709+ var asmPrototype = new ProjectModule ( ) ;
710+ asmPrototype . Load ( elem ) ;
711+
712+ foreach ( string fileName in files ) {
713+ var moduleEntry = asmPrototype . Clone ( ) ;
714+ moduleEntry . Path = fileName ;
715+ Add ( moduleEntry ) ;
716+ }
717+
718+ return true ;
719+ }
684720 /// <summary>
685721 /// Clones this instance.
686722 /// </summary>
0 commit comments