Skip to content

Commit 312ed48

Browse files
committed
implemented VBProject extension to import source files
1 parent df763bf commit 312ed48

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

RetailCoder.VBE/Extensions/VbProjectExtensions.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,29 @@ public static void RemoveAllComponents(this VBProject project)
6161
}
6262
}
6363

64-
//todo: Implement ImportSourceFiles. Don't import .frx files. DocClasses need to imported by writing to module from file.
64+
/// <summary>
65+
/// Imports all source code files from target directory into project.
66+
/// </summary>
67+
/// <remarks>
68+
/// Only files with extensions "cls", "bas, "frm", and "doccls" are imported.
69+
/// It is the callers responsibility to remove any existing components prior to importing.
70+
/// </remarks>
71+
/// <param name="project"></param>
72+
/// <param name="filePath">Directory path containing the source files.</param>
73+
public static void ImportSourceFiles(this VBProject project, string filePath)
74+
{
75+
var dirInfo = new System.IO.DirectoryInfo(filePath);
76+
77+
var files = dirInfo.EnumerateFiles()
78+
.Where(f => f.Extension == VBComponentExtensions.StandardExtension ||
79+
f.Extension == VBComponentExtensions.ClassExtesnion ||
80+
f.Extension == VBComponentExtensions.DocClassExtension ||
81+
f.Extension == VBComponentExtensions.FormExtension
82+
);
83+
foreach (var file in files)
84+
{
85+
project.VBComponents.ImportSourceFile(file.FullName);
86+
}
87+
}
6588
}
6689
}

RetailCoder.VBE/SourceControl/SourceControlProviderBase.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,7 @@ public virtual void Revert()
8282
private void Refresh()
8383
{
8484
this.project.RemoveAllComponents();
85-
86-
var dirInfo = new System.IO.DirectoryInfo(this.CurrentRepository.LocalLocation);
87-
88-
var files = dirInfo.EnumerateFiles()
89-
.Where(f => f.Extension == VBComponentExtensions.StandardExtension||
90-
f.Extension == VBComponentExtensions.ClassExtesnion ||
91-
f.Extension == VBComponentExtensions.DocClassExtension ||
92-
f.Extension == VBComponentExtensions.FormExtension
93-
);
94-
foreach (var file in files)
95-
{
96-
this.project.VBComponents.ImportSourceFile(file.FullName);
97-
}
85+
this.project.ImportSourceFiles(this.CurrentRepository.LocalLocation);
9886
}
9987
}
10088
}

0 commit comments

Comments
 (0)