From: Scott H. <sk...@us...> - 2002-05-31 18:35:18
|
Update of /cvsroot/nant/nant/src/Extras/SLiNgshoT/SLiNgshoT.Core In directory usw-pr-cvs1:/tmp/cvs-serv12161/SLiNgshoT.Core Added Files: AssemblyInfo.cs Attributes.cs Configuration.cs Driver.cs File.cs NAntWriter.cs NMakeWriter.cs Project.cs Reference.cs SLiNgshoT.Core.csproj Solution.cs SolutionWriter.cs Log Message: Initial checkin. SLiNgshoT provided by Jason Diamond (ja...@in...) --- NEW FILE: AssemblyInfo.cs --- using System.Reflection; using System.Runtime.CompilerServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly: AssemblyTitle("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")] --- NEW FILE: Attributes.cs --- using System; namespace SLiNgshoT.Core { public class OutputFormatAttribute : Attribute { public OutputFormatAttribute(string name) { this.name = name; } private string name; public string Name { get { return name; } } } public class OutputParameterAttribute : Attribute { public OutputParameterAttribute(string name, bool required, string description) { this.name = name; this.required = required; this.description = description; } private string name; bool required; string description; public string Name { get { return name; } } public bool Required { get { return required; } } public string Description { get { return description; } } } } --- NEW FILE: Configuration.cs --- // Configuration.cs - the Configuration class // Copyright (C) 2001, 2002 Jason Diamond // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections; using System.IO; using System.Text.RegularExpressions; using System.Xml; using System.Xml.XPath; namespace SLiNgshoT.Core { /// <summary>Represents a configuration (usually Release or Debug).</summary> public class Configuration { private XPathNavigator _Navigator; internal Configuration(XPathNavigator navigator) { _Navigator = navigator.Clone(); } /// <summary>Gets the name of the configuration.</summary> /// <remarks>This is usually "Debug" or "Release".</remarks> public string Name { get { return (string)_Navigator.Evaluate("string(@Name)"); } } /// <summary>Gets the location of the output files (relative to the /// project directory) for this project's configuration.</summary> public string OutputPath { get { return (string)_Navigator.Evaluate("string(@OutputPath)"); } } /// <summary>Gets the name of the file (relative to the project /// directory) into which documentation comments will be /// processed.</summary> public string DocumentationFile { get { return (string)_Navigator.Evaluate("string(@DocumentationFile)"); } } public bool DebugSymbols { get { return (bool)_Navigator.Evaluate("boolean(@DebugSymbols='true')"); } } public bool AllowUnsafeBlocks { get { return (bool)_Navigator.Evaluate("boolean(@AllowUnsafeBlocks='true')"); } } public bool CheckForOverflowUnderflow { get { return (bool)_Navigator.Evaluate("boolean(@CheckForOverflowUnderflow='true')"); } } public string DefineConstants { get { return (string)_Navigator.Evaluate("string(@DefineConstants)"); } } } } --- NEW FILE: Driver.cs --- // Driver.cs - the SLiNgshoT entry point // Copyright (C) 2001, 2002 Jason Diamond // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections; using System.IO; using System.Reflection; namespace SLiNgshoT.Core { public class Driver { public static IList GetOutputFormats() { ArrayList outputFormats = new ArrayList(); Assembly assembly = typeof(Driver).Assembly; foreach (Type type in assembly.GetTypes()) { if (type.GetInterface(typeof(SolutionWriter).FullName) != null) { OutputFormatAttribute outputFormat = Attribute.GetCustomAttribute(type, typeof(OutputFormatAttribute)) as OutputFormatAttribute; if (outputFormat != null) { outputFormats.Add(outputFormat.Name); } } } outputFormats.Sort(); return outputFormats; } private static Type GetSolutionWriterImplementation(string format) { Assembly assembly = typeof(Driver).Assembly; foreach (Type type in assembly.GetTypes()) { if (type.GetInterface(typeof(SolutionWriter).FullName) != null) { OutputFormatAttribute outputFormat = Attribute.GetCustomAttribute(type, typeof(OutputFormatAttribute)) as OutputFormatAttribute; if (outputFormat != null && outputFormat.Name == format) { return type; } } } return null; } public static OutputParameterAttribute[] GetOutputParameters(string format) { Type type = GetSolutionWriterImplementation(format); if (type != null) { object[] outputParameterAttributes = type.GetCustomAttributes(typeof(OutputParameterAttribute), true); OutputParameterAttribute[] outputParameters = new OutputParameterAttribute[outputParameterAttributes.Length]; for (int i = 0; i < outputParameterAttributes.Length; ++i) { outputParameters[i] = outputParameterAttributes[i] as OutputParameterAttribute; } return outputParameters; } return new OutputParameterAttribute[0]; } public static void ParseArgs(string[] args, out string format, out string solution, Hashtable parameters, Hashtable uriMap) { format = null; solution = null; for (int i = 0; i < args.Length; ++i) { string arg = args[i]; if (arg[0] == '/' || arg[0] == '-') { string argName = arg.Substring(1); switch (argName) { case "sln": solution = args[++i]; break; case "map": if (i + 2 < args.Length) { string uriPrefix = args[++i]; string filePrefix = args[++i]; uriMap.Add(uriPrefix, filePrefix); } else { Console.Error.WriteLine("not enough arguments left for -map option"); } break; default: format = argName; break; } } else { int indexOfEquals = arg.IndexOf('='); if (indexOfEquals != -1) { string name = arg.Substring(0, indexOfEquals); string value = arg.Substring(indexOfEquals + 1); parameters.Add(name, value); } else { Console.Error.WriteLine("unknown argument: {0}", arg); } } } } public static string FindSolution(string directory) { string[] files = Directory.GetFiles(directory, "*.sln"); if (files.Length == 0) { throw new ApplicationException(String.Format("{0} does not contain any '.sln' files", directory)); } else if (files.Length > 1) { throw new ApplicationException(String.Format("{0} contains too many '.sln' files", directory)); } return files[0]; } public static void WriteSolution( SolutionWriter writer, TextWriter textWriter, string sln, Hashtable parameters, Hashtable uriMap) { writer.SetOutput(textWriter); writer.SetParameters(parameters); Solution solution = new Solution(); solution.Read(sln, uriMap); writer.WriteStartSolution(solution); foreach (Project project in solution.GetProjects()) { IList sourceFiles = project.GetSourceFiles(); if (sourceFiles.Count > 0) { writer.WriteStartProjectSourceFiles(project); foreach (File file in sourceFiles) { writer.WriteProjectSourceFile(file); } writer.WriteEndProjectSourceFiles(); } IList resXFiles = project.GetResXResourceFiles(); if (resXFiles.Count > 0) { writer.WriteStartProjectResXResourceFiles(project); foreach (File file in resXFiles) { writer.WriteProjectResXResourceFile(file); } writer.WriteEndProjectResXResourceFiles(); } IList resourceFiles = project.GetNonResXResourceFiles(); if (resourceFiles.Count > 0) { writer.WriteStartProjectNonResXResourceFiles(project); foreach (File file in resourceFiles) { writer.WriteProjectNonResXResourceFile(file); } writer.WriteEndProjectNonResXResourceFiles(); } } foreach (Project project in solution.GetProjects()) { if (project.CountFiles("Compile") > 0) { writer.WriteStartProject(project); writer.WriteStartProjectDependencies(); foreach (Project dependency in solution.GetDependencies(project)) { writer.WriteProjectDependency(dependency); } foreach (Reference reference in project.GetReferences()) { if (reference.Type == "Project") { writer.WriteProjectDependency(solution.GetProject(reference.Value)); } } foreach (File file in project.GetFiles()) { if (!file.RelativePath.EndsWith(".licx")) { writer.WriteProjectDependency(file); } } writer.WriteEndProjectDependencies(); IList resXFiles = project.GetResXResourceFiles(); if (resXFiles.Count > 0) { writer.WriteStartResXFiles(); foreach (File file in resXFiles) { writer.WriteResXFile(file); } writer.WriteEndResXFiles(); } writer.WriteStartAssembly(); IList sourceFiles = project.GetSourceFiles(); if (sourceFiles.Count > 0) { writer.WriteStartSourceFiles(); foreach (File file in sourceFiles) { writer.WriteSourceFile(file); } writer.WriteEndSourceFiles(); } writer.WriteStartReferences(); // Write out the standard system references. foreach (Reference reference in project.GetSystemReferences()) { if (reference != null) { if (reference.Value.StartsWith("System")) writer.WriteReference(reference.Value + ".dll", false); else writer.WriteReference(reference.Value + ".dll", true); } } // Write out the project references. foreach (Project referencedProject in project.GetReferencedProjects()) { writer.WriteReference(referencedProject); } writer.WriteEndReferences(); writer.WriteStartResources(); foreach (File file in project.GetResXResourceFiles()) { string path = project.RootNamespace + "." + Path.GetFileNameWithoutExtension(file.RelativePath) + ".resources"; writer.WriteResource(path, null, true); } foreach (File file in project.GetNonResXResourceFiles()) { writer.WriteResource( file.RelativePathFromSolutionDirectory, file.ResourceName, false); } writer.WriteEndResources(); writer.WriteEndAssembly(); // Write out the project references so that they can be copied. writer.WriteStartCopyProjectAssemblies(); foreach (Project referencedProject in project.GetReferencedProjects()) { writer.WriteCopyProjectAssembly(referencedProject); } writer.WriteEndCopyProjectAssemblies(); writer.WriteEndProject(); } } writer.WriteStartCleanTarget(); foreach (Project project in solution.GetProjects()) { writer.WriteCleanProject(project); } writer.WriteEndCleanTarget(); writer.WriteEndSolution(); } } } --- NEW FILE: File.cs --- // File.cs - the File class // Copyright (C) 2001, 2002 Jason Diamond // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections; using System.IO; using System.Text.RegularExpressions; using System.Xml; using System.Xml.XPath; namespace SLiNgshoT.Core { /// <summary>Represents a file in a project.</summary> public class File { private Project _Project; private XPathNavigator _Navigator; internal File(Project project, XPathNavigator navigator) { _Project = project; _Navigator = navigator.Clone(); } /// <summary>Gets the relative path to the file (from the /// project directory).</summary> public string RelativePath { get { return (string)_Navigator.Evaluate("string(@RelPath)"); } } /// <summary>Gets the BuildAction for the file.</summary> /// <value>"Compile", "EmbeddedResource", or "Content"</value> public string BuildAction { get { return (string)_Navigator.Evaluate("string(@BuildAction)"); } } /// <summary>Gets relative path to the file (from the solution /// directory).</summary> public string RelativePathFromSolutionDirectory { get { return Path.Combine(_Project.RelativePath, RelativePath); } } /// <summary>Gets the absolute path to the file.</summary> public string AbsolutePath { get { return Path.Combine( _Project.Solution.SolutionDirectory, RelativePathFromSolutionDirectory); } } /// <summary>Gets the "default" name for this resource.</summary> /// <remarks>This is usually the RootNamespace plus the relative /// path to the file with all backslashes replaced with dots.</remarks> public string ResourceName { get { return _Project.RootNamespace + "." + RelativePath.Replace('\\', '.'); } } } } --- NEW FILE: NAntWriter.cs --- // NAntWriter.cs - a NAnt .build file writer // Copyright (C) 2001, 2002 Jason Diamond // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections; using System.IO; using System.Xml; namespace SLiNgshoT.Core { [OutputFormat("nant")] [OutputParameter("build.basedir", true, "Specifies the parent directory for the individual configuration directories.")] public class NAntWriter : SolutionWriter { public NAntWriter() { } private XmlTextWriter writer; private Solution solution; private Project project; private string depends; private Hashtable parameters; public void SetOutput(TextWriter output) { writer = new XmlTextWriter(output); writer.Formatting = Formatting.Indented; } public void SetParameters(Hashtable parameters) { this.parameters = parameters; } private void WriteProperty(string name, string value) { writer.WriteStartElement("property"); writer.WriteAttributeString("name", name); writer.WriteAttributeString("value", value); writer.WriteEndElement(); // property } public void WriteStartSolution(Solution solution) { this.solution = solution; //writer.WriteStartDocument(); writer.WriteComment(" Generated by SLiNgshoT <http://injektilo.org/> "); writer.WriteStartElement("project"); writer.WriteAttributeString("name", solution.SolutionName); writer.WriteAttributeString("default", "Debug"); WriteProperty("build.basedir", (string)parameters["build.basedir"]); foreach (string configurationName in solution.GetConfigurationNames()) { writer.WriteStartElement("target"); writer.WriteAttributeString("name", configurationName); string depends = null; foreach (Project project in solution.GetProjects()) { Configuration configuration = project.GetConfiguration(configurationName); if (configuration != null) { if (depends != null) { depends += ","; } depends += project.Name + "." + configurationName; } } writer.WriteAttributeString("depends", depends); writer.WriteEndElement(); // target } WriteSetupTarget(); } private void WriteSetupTarget() { writer.WriteStartElement("target"); writer.WriteAttributeString("name", "setup"); writer.WriteStartElement("mkdir"); writer.WriteAttributeString("dir", "${build.dir}"); writer.WriteEndElement(); // mkdir writer.WriteEndElement(); // target } public void WriteStartProjectSourceFiles(Project project) { } public void WriteProjectSourceFile(File file) { } public void WriteEndProjectSourceFiles() { } public void WriteStartProjectResXResourceFiles(Project project) { } public void WriteProjectResXResourceFile(File file) { } public void WriteEndProjectResXResourceFiles() { } public void WriteStartProjectNonResXResourceFiles(Project project) { } public void WriteProjectNonResXResourceFile(File file) { } public void WriteEndProjectNonResXResourceFiles() { } public void WriteStartProject(Project project) { this.project = project; foreach (Configuration configuration in project.GetConfigurations()) { writer.WriteStartElement("target"); writer.WriteAttributeString("name", project.Name + "." + configuration.Name); depends = null; foreach (Project dependency in solution.GetDependencies(project)) { if (depends != null) { depends += ","; } depends += dependency.Name + "." + configuration.Name; } foreach (Project projectReference in project.GetReferencedProjects()) { if (depends != null) { depends += ","; } depends += projectReference.Name + "." + configuration.Name; } if (depends != null) { writer.WriteAttributeString("depends", depends); } WriteProperty("project.name", project.Name); WriteProperty("build.dir", "${build.basedir}\\" + configuration.Name); //WriteProperty("directory", Path.GetDirectoryName(project.GetRelativeOutputPathForConfiguration(configuration.Name))); WriteProperty("output", "${build.dir}\\" + Path.GetFileName(project.GetRelativeOutputPathForConfiguration(configuration.Name))); WriteProperty("debug", configuration.DebugSymbols ? "true" : "false"); #warning fix this once NAnt supports unsafe & checked WriteProperty("unsafe", "/unsafe" + (configuration.AllowUnsafeBlocks ? "+" : "-")); //WriteProperty("unsafe", configuration.AllowUnsafeBlocks ? "true" : "false"); WriteProperty("checked", "/checked" + (configuration.CheckForOverflowUnderflow ? "+" : "-")); WriteProperty("define", configuration.DefineConstants); string documentationFile = Path.GetFileName(project.GetRelativePathToDocumentationFile(configuration.Name)); if (documentationFile == null || documentationFile.Length == 0) { WriteProperty("doc", ""); } else { WriteProperty("doc", "${build.dir}\\" + Path.GetFileName(project.GetRelativePathToDocumentationFile(configuration.Name))); } writer.WriteStartElement("call"); writer.WriteAttributeString("target", project.Name); writer.WriteEndElement(); // call writer.WriteEndElement(); // target } writer.WriteStartElement("target"); writer.WriteAttributeString("name", project.Name); } public void WriteStartProjectDependencies() { depends = "setup"; } public void WriteProjectDependency(Project project) { //depends += "," + project.Name; } public void WriteProjectDependency(File file) { } public void WriteEndProjectDependencies() { writer.WriteAttributeString("depends", depends); } public void WriteStartResXFiles() { } public void WriteResXFile(File file) { writer.WriteStartElement("resgen"); writer.WriteAttributeString("input", file.RelativePathFromSolutionDirectory); writer.WriteAttributeString( "output", "${build.dir}\\" + project.RootNamespace + "." + Path.GetFileNameWithoutExtension(file.RelativePath) + ".resources"); writer.WriteEndElement(); // resgen } public void WriteEndResXFiles() { } public void WriteStartAssembly() { writer.WriteStartElement("csc"); writer.WriteAttributeString("target", project.OutputType.ToLower()); writer.WriteAttributeString("output", "${output}"); writer.WriteAttributeString("debug", "${debug}"); #warning uncomment this once NAnt supports unsafe and checked //writer.WriteAttributeString("unsafe", "${unsafe}"); //writer.WriteAttributeString("checked", "${checked}"); writer.WriteAttributeString("define", "${define}"); writer.WriteAttributeString("doc", "${doc}"); #warning remove these once NAnt supports unsafe and checked writer.WriteStartElement("arg"); writer.WriteAttributeString("value", "${unsafe}"); writer.WriteEndElement(); writer.WriteStartElement("arg"); writer.WriteAttributeString("value", "${checked}"); writer.WriteEndElement(); } public void WriteStartSourceFiles() { writer.WriteStartElement("sources"); } public void WriteSourceFile(File file) { writer.WriteStartElement("includes"); writer.WriteAttributeString( "name", file.RelativePathFromSolutionDirectory); writer.WriteEndElement(); // includes } public void WriteEndSourceFiles() { writer.WriteEndElement(); // sources } public void WriteStartReferences() { writer.WriteStartElement("references"); } public void WriteReference(string name, bool built) { string path = built ? "${build.dir}\\" + name : name; writer.WriteStartElement("includes"); writer.WriteAttributeString("name", path); writer.WriteEndElement(); // includes } public void WriteReference(Project project) { writer.WriteStartElement("includes"); writer.WriteAttributeString("name", "${build.dir}\\" + project.OutputFile); writer.WriteEndElement(); // includes } public void WriteEndReferences() { writer.WriteEndElement(); // references } public void WriteStartResources() { } public void WriteResource(string path, string name, bool built) { string arg = "/resource:"; if (built) { arg += "${build.dir}\\"; } arg += path; writer.WriteStartElement("arg"); if (name != null) { arg += "," + name; } writer.WriteAttributeString("value", arg); writer.WriteEndElement(); // arg } public void WriteEndResources() { } public void WriteStartCopyProjectAssemblies() { //writer.WriteStartElement("copy"); //writer.WriteAttributeString("todir", "${build.dir}"); //writer.WriteStartElement("fileset"); } public void WriteCopyProjectAssembly(Project project) { //writer.WriteStartElement("includes"); //writer.WriteAttributeString("name", project.Name); //writer.WriteEndElement(); // includes } public void WriteEndCopyProjectAssemblies() { //writer.WriteEndElement(); // fileset //writer.WriteEndElement(); // copy } public void WriteEndAssembly() { writer.WriteEndElement(); // csc } public void WriteEndProject() { writer.WriteEndElement(); // target } public void WriteStartCleanTarget() { writer.WriteStartElement("target"); writer.WriteAttributeString("name", "DebugClean"); WriteProperty("build.dir","${build.basedir}\\Debug"); writer.WriteStartElement("call"); writer.WriteAttributeString("target", "Clean"); writer.WriteEndElement(); // call writer.WriteEndElement(); // target DebugClean writer.WriteStartElement("target"); writer.WriteAttributeString("name", "ReleaseClean"); WriteProperty("build.dir","${build.basedir}\\Release"); writer.WriteStartElement("call"); writer.WriteAttributeString("target", "Clean"); writer.WriteEndElement(); // call writer.WriteEndElement(); // target ReleaseClean writer.WriteStartElement("target"); writer.WriteAttributeString("name", "Clean"); } public void WriteCleanProject(Project project) { writer.WriteStartElement("delete"); writer.WriteAttributeString("file", "${build.dir}\\" + project.OutputFile); writer.WriteAttributeString("failonerror", "false"); writer.WriteEndElement(); // delete writer.WriteStartElement("delete"); writer.WriteAttributeString("file", "${build.dir}\\" + project.AssemblyName + ".pdb"); writer.WriteAttributeString("failonerror", "false"); writer.WriteEndElement(); // delete foreach (File file in project.GetResXResourceFiles()) { string path = project.RootNamespace + "." + Path.GetFileNameWithoutExtension(file.RelativePath) + ".resources"; writer.WriteStartElement("delete"); writer.WriteAttributeString("file", "${build.dir}\\" + path); writer.WriteAttributeString("failonerror", "false"); writer.WriteEndElement(); // delete } foreach (File file in project.GetNonResXResourceFiles()) { writer.WriteStartElement("delete"); writer.WriteAttributeString("file", file.RelativePathFromSolutionDirectory + file.ResourceName); writer.WriteAttributeString("failonerror", "false"); writer.WriteEndElement(); // delete } } public void WriteEndCleanTarget() { writer.WriteEndElement(); // target Clean } public void WriteEndSolution() { writer.WriteEndElement(); // project //writer.WriteEndDocument(); } } } --- NEW FILE: NMakeWriter.cs --- // NMakeWriter.cs - a Makefile writer // Copyright (C) 2001, 2002 Jason Diamond // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections; using System.IO; namespace SLiNgshoT.Core { [OutputFormat("nmake")] public class NMakeWriter : SolutionWriter { public NMakeWriter() { } private TextWriter writer; private Solution solution; private Project project; public void SetOutput(TextWriter output) { writer = output; } public void SetParameters(Hashtable parameters) { } private string GetProjectName(Project project) { return project.Name.Replace('.', '_').ToUpper(); } public void WriteStartSolution(Solution solution) { this.solution = solution; writer.WriteLine("# Generated by SLiNgshoT <http://injektilo.org/>"); writer.WriteLine(); writer.WriteLine("!IFNDEF CFG"); writer.WriteLine(); writer.WriteLine("CFG = Debug"); writer.WriteLine(); writer.WriteLine("!ENDIF"); writer.WriteLine(); bool firstConfig = true; foreach (string configurationName in solution.GetConfigurationNames()) { if (firstConfig) { writer.Write("!IF"); firstConfig = false; } else { writer.Write("!ELSE IF"); } writer.WriteLine(" \"$(CFG)\" == \"{0}\"", configurationName); writer.WriteLine(); foreach (Project project in solution.GetProjects()) { Configuration configuration = project.GetConfiguration(configurationName); writer.WriteLine( GetProjectName(project) + "_DIRECTORY = " + Path.GetDirectoryName(project.GetRelativeOutputPathForConfiguration(configurationName))); writer.WriteLine( GetProjectName(project) + " = $(" + GetProjectName(project) + "_DIRECTORY)\\" + Path.GetFileName(project.GetRelativeOutputPathForConfiguration(configurationName))); writer.WriteLine( GetProjectName(project) + "_DEBUG = /debug" + (configuration.DebugSymbols ? "+" : "-")); writer.WriteLine( GetProjectName(project) + "_UNSAFE = /unsafe" + (configuration.AllowUnsafeBlocks ? "+" : "-")); writer.Write(GetProjectName(project) + "_DEFINES ="); string defineConstants = configuration.DefineConstants; if (defineConstants != null && defineConstants.Length > 0) { writer.Write(" /define:" + defineConstants); } writer.WriteLine(); string documentationFile = Path.GetFileName(project.GetRelativePathToDocumentationFile(configurationName)); if (documentationFile != null && documentationFile.Length > 0) { writer.WriteLine( GetProjectName(project) + "_DOC = /doc:$(" + GetProjectName(project) + "_DIRECTORY)\\" + documentationFile); } else { writer.WriteLine("{0}_DOC =", GetProjectName(project)); } writer.WriteLine(); } } writer.WriteLine("!ENDIF"); writer.WriteLine(); writer.Write("all:"); foreach (Project project in solution.GetProjects()) { if (project.CountFiles("Compile") > 0) { writer.Write(" $(" + GetProjectName(project) + ")"); } } writer.WriteLine(); writer.WriteLine(); } public void WriteStartProjectSourceFiles(Project project) { this.project = project; writer.Write("{0}_SOURCE_FILES =", GetProjectName(project)); } public void WriteProjectSourceFile(File file) { writer.WriteLine(" \\"); writer.Write("\t{0}", file.RelativePathFromSolutionDirectory); } public void WriteEndProjectSourceFiles() { writer.WriteLine(); writer.WriteLine(); } public void WriteStartProjectResXResourceFiles(Project project) { this.project = project; writer.Write("{0}_RESX_FILES =", GetProjectName(project)); } public void WriteProjectResXResourceFile(File file) { writer.WriteLine(" \\"); writer.Write("\t{0}", file.RelativePathFromSolutionDirectory); } public void WriteEndProjectResXResourceFiles() { writer.WriteLine(); writer.WriteLine(); } public void WriteStartProjectNonResXResourceFiles(Project project) { this.project = project; writer.Write("{0}_RESOURCE_FILES =", GetProjectName(project)); } public void WriteProjectNonResXResourceFile(File file) { writer.WriteLine(" \\"); writer.Write("\t{0}", file.RelativePathFromSolutionDirectory); } public void WriteEndProjectNonResXResourceFiles() { writer.WriteLine(); writer.WriteLine(); } public void WriteStartProject(Project project) { this.project = project; writer.Write("$(" + GetProjectName(project) + "):"); } public void WriteStartProjectDependencies() { } public void WriteProjectDependency(Project project) { writer.Write(" $(" + GetProjectName(project) + ")"); } public void WriteProjectDependency(File file) { } public void WriteEndProjectDependencies() { writer.Write(" $({0}_SOURCE_FILES)", GetProjectName(project)); if (project.GetResXResourceFiles().Count > 0) { writer.Write(" $({0}_RESX_FILES)", GetProjectName(project)); } if (project.GetNonResXResourceFiles().Count > 0) { writer.Write(" $({0}_RESOURCE_FILES)", GetProjectName(project)); } writer.WriteLine(); writer.WriteLine("\tif not exist $(" + GetProjectName(project) + "_DIRECTORY) md $(" + GetProjectName(project) + "_DIRECTORY)"); } public void WriteStartResXFiles() { } public void WriteResXFile(File file) { writer.WriteLine("\tresgen " + file.RelativePathFromSolutionDirectory + " $(" + GetProjectName(project) + "_DIRECTORY)\\" + project.RootNamespace + "." + Path.GetFileNameWithoutExtension(file.RelativePath) + ".resources"); } public void WriteEndResXFiles() { } public void WriteStartAssembly() { writer.Write("\tcsc /nologo /target:" + project.OutputType.ToLower() + " /out:" + "$(" + GetProjectName(project) + ")" + " $(" + GetProjectName(project) + "_DEBUG)" + " $(" + GetProjectName(project) + "_UNSAFE)" + " $(" + GetProjectName(project) + "_DEFINES)" + " $(" + GetProjectName(project) + "_DOC)"); } public void WriteStartSourceFiles() { writer.Write(" $({0}_SOURCE_FILES)", GetProjectName(project)); } public void WriteSourceFile(File file) { } public void WriteEndSourceFiles() { } public void WriteStartReferences() { } public void WriteReference(string name, bool built) { writer.Write(" /reference:"); if (built) { writer.Write("$(" + GetProjectName(project) + "_DIRECTORY)\\"); } writer.Write(name); } public void WriteReference(Project project) { writer.Write(" /reference:$(" + GetProjectName(project) + ")"); } public void WriteEndReferences() { // <arg value="/lib:${build.dir}" /> // writer.Write(" /reference:$(" + GetProjectName(project) + ")"); } public void WriteStartResources() { } public void WriteResource(string path, string name, bool built) { writer.Write(" /resource:"); if (built) { writer.Write("$(" + GetProjectName(project) + "_DIRECTORY)\\"); } writer.Write(path); if (name != null) { writer.Write("," + name); } } public void WriteEndResources() { } public void WriteStartCopyProjectAssemblies() { } public void WriteCopyProjectAssembly(Project project) { writer.WriteLine( "\tcopy $({0}) $({1}_DIRECTORY)", GetProjectName(project), GetProjectName(this.project)); } public void WriteEndCopyProjectAssemblies() { } public void WriteEndAssembly() { writer.WriteLine(); } public void WriteEndProject() { writer.WriteLine(); } public void WriteStartCleanTarget() { writer.WriteLine("clean:"); } public void WriteCleanProject(Project project) { writer.WriteLine("\trd /s /q $({0}_DIRECTORY)", GetProjectName(project)); } public void WriteEndCleanTarget() { } public void WriteEndSolution() { } } } --- NEW FILE: Project.cs --- // Project.cs - the Project class // Copyright (C) 2001, 2002 Jason Diamond // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections; using System.IO; using System.Text.RegularExpressions; using System.Xml; using System.Xml.XPath; namespace SLiNgshoT.Core { /// <summary>Represents a project in a solution.</summary> public class Project { internal Project(Solution solution, Guid id, string name) { _Solution = solution; _ID = id; _Name = name; } private Solution _Solution; /// <summary>Gets the solution that contains this project.</summary> public Solution Solution { get { return _Solution; } } private string _RelativePath; /// <summary>Gets or sets the relative path (from the solution /// directory) to the project directory.</summary> public string RelativePath { get { return _RelativePath; } set { _RelativePath = value; } } private Guid _ID; /// <summary>Gets the GUID that identifies the project.</summary> public Guid ID { get { return _ID; } } private string _Name; /// <summary>Gets the name of the project.</summary> public string Name { get { return _Name; } } private XPathDocument _ProjectDocument; private XPathNavigator _ProjectNavigator; /// <summary>Reads the project file from the specified path.</summary> /// <param name="path">The path to the project file.</param> public void Read(string path) { string extension = Path.GetExtension(path); if (extension == ".csproj" || extension == ".vcproj") { _ProjectDocument = new XPathDocument(path); _ProjectNavigator = _ProjectDocument.CreateNavigator(); } } /// <summary>Gets a string that represents the type of project.</summary> /// <value>"Visual C++" or "C# Local"</value> public string ProjectType { get { string projectType = ""; if (_ProjectNavigator != null) { if ((bool)_ProjectNavigator.Evaluate("boolean(VisualStudioProject/@ProjectType='Visual C++')")) { projectType = "Visual C++"; } else if ((bool)_ProjectNavigator.Evaluate("boolean(VisualStudioProject/CSHARP/@ProjectType='Local')")) { projectType = "C# Local"; } else if ((bool)_ProjectNavigator.Evaluate("boolean(VisualStudioProject/CSHARP/@ProjectType='Web')")) { projectType = "C# Web"; } } return projectType; } } /// <summary>Gets the name of the assembly this project generates.</summary> public string AssemblyName { get { string assemblyName = ""; if (_ProjectNavigator != null) { assemblyName = (string)_ProjectNavigator.Evaluate("string(/VisualStudioProject/CSHARP/Build/Settings/@AssemblyName)"); } return assemblyName; } } /// <summary>Gets the output type of the project.</summary> /// <value>"Library", "Exe", or "WinExe"</value> public string OutputType { get { string outputType = ""; if (_ProjectNavigator != null) { outputType = (string)_ProjectNavigator.Evaluate("string(/VisualStudioProject/CSHARP/Build/Settings/@OutputType)"); } return outputType; } } /// <summary>Gets the filename of the generated assembly.</summary> public string OutputFile { get { string extension = ""; switch (OutputType) { case "Library": extension = ".dll"; break; case "Exe": extension = ".exe"; break; case "WinExe": extension = ".exe"; break; } return AssemblyName + extension; } } /// <summary>Gets the default namespace for the project.</summary> public string RootNamespace { get { return (string)_ProjectNavigator.Evaluate("string(/VisualStudioProject/CSHARP/Build/Settings/@RootNamespace)"); } } public ArrayList GetConfigurations() { ArrayList configurations = new ArrayList(); XPathNodeIterator nodes = _ProjectNavigator.Select("/VisualStudioProject/CSHARP/Build/Settings/Config"); while (nodes.MoveNext()) { configurations.Add(new Configuration(nodes.Current)); } return configurations; } /// <summary>Gets the configuration with the specified name.</summary> /// <param name="name">"Debug" or "Release"</param> /// <returns>A Configuration object.</returns> public Configuration GetConfiguration(string name) { XPathNavigator navigator = null; XPathNodeIterator nodes = _ProjectNavigator.Select( String.Format( "/VisualStudioProject/CSHARP/Build/Settings/Config[@Name='{0}']", name)); if (nodes.MoveNext()) { navigator = nodes.Current; } return new Configuration(navigator); } /// <summary>Gets the relative path (from the project directory) to the /// assembly this project generates.</summary> /// <param name="name">A configuration name.</param> public string GetRelativeOutputPathForConfiguration(string name) { return Path.Combine( Path.Combine(RelativePath, GetConfiguration(name).OutputPath), OutputFile); } /// <summary>Gets the relative path (from the project directory) to the /// XML documentation this project generates.</summary> /// <param name="name">A configuration name.</param> public string GetRelativePathToDocumentationFile(string name) { string path = null; string documentationFile = GetConfiguration(name).DocumentationFile; if (documentationFile != null && documentationFile.Length > 0) { path = Path.Combine(RelativePath, documentationFile); } return path; } private ArrayList _References; /// <summary>Gets an enumerable list of reference objects this project /// references.</summary> public IEnumerable GetReferences() { if (_References == null) { if (_ProjectNavigator != null) { _References = new ArrayList(); XPathNodeIterator nodes = _ProjectNavigator.Select("/VisualStudioProject/CSHARP/Build/References/Reference"); while (nodes.MoveNext()) { Reference reference = new Reference(_Solution, nodes.Current); _References.Add(reference); } } } return _References; } /// <summary>Gets a list of projects that this project references.</summary> public IList GetSystemReferences() { ArrayList projects = new ArrayList(); foreach (Reference reference in GetReferences()) { if ((reference.Type == "AssemblyName") || (reference.Type == "Guid")) { projects.Add(reference); } } return projects; } /// <summary>Gets a list of projects that this project references.</summary> public IList GetReferencedProjects() { ArrayList projects = new ArrayList(); foreach (Reference reference in GetReferences()) { if (reference.Type == "Project") { projects.Add(_Solution.GetProject(reference.Value)); } } return projects; } private ArrayList _Files; /// <summary>Gets an enumerable list of files contained in this project.</summary> public IEnumerable GetFiles() { if (_Files == null) { _Files = new ArrayList(); XPathNodeIterator nodes = _ProjectNavigator.Select("/VisualStudioProject/CSHARP/Files/Include/File"); while (nodes.MoveNext()) { _Files.Add(new File(this, nodes.Current)); } } return _Files; } /// <summary>Counts the files with the specified build action property.</summary> /// <param name="buildAction">"Compile", "EmbeddedResource", or "Content"</param> public int CountFiles(string buildAction) { int count = 0; foreach (File file in GetFiles()) { if (file.BuildAction == buildAction) { ++count; } } return count; } public IList GetSourceFiles() { ArrayList list = new ArrayList(); foreach (File file in GetFiles()) { if (file.BuildAction == "Compile") { list.Add(file); } } return list; } public IList GetResXResourceFiles() { ArrayList list = new ArrayList(); foreach (File file in GetFiles()) { if (file.BuildAction == "EmbeddedResource") { if (Path.GetExtension(file.RelativePath).ToLower() == ".resx") { long length = GetFileLength(file.AbsolutePath); if (length > 0) { list.Add(file); } } } } return list; } private static long GetFileLength(string path) { long length = 0; Stream stream = null; try { stream = System.IO.File.OpenRead(path); length = stream.Length; } finally { if (stream != null) { stream.Close(); } } return length; } public IList GetNonResXResourceFiles() { ArrayList list = new ArrayList(); foreach (File file in GetFiles()) { if (file.BuildAction == "EmbeddedResource") { if (Path.GetExtension(file.RelativePath).ToLower() != ".resx") { list.Add(file); } } } return list; } } } --- NEW FILE: Reference.cs --- // Reference.cs - the Reference class // Copyright (C) 2001, 2002 Jason Diamond // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections; using System.IO; using System.Text.RegularExpressions; using System.Xml; using System.Xml.XPath; namespace SLiNgshoT.Core { /// <summary>Represents a project reference.</summary> public class Reference { private Solution _Solution; private XPathNavigator _Navigator; internal Reference(Solution solution, XPathNavigator navigator) { _Solution = solution; _Navigator = navigator.Clone(); } /// <summary>Gets a string identifying the type of reference.</summary> /// <value>"AssemblyName", "Project" or "Guid"</value> public string Type { get { string type = null; if ((bool)_Navigator.Evaluate("boolean(@AssemblyName)")) { type = "AssemblyName"; } else if ((bool)_Navigator.Evaluate("boolean(@Project)")) { type = "Project"; } else if ((bool)_Navigator.Evaluate("boolean(@Guid)")) { type = "Guid"; } return type; } } /// <summary>Gets the "value" of this reference.</summary> /// <value>If the reference type is "AssemblyName" this will be the /// name of a system assembly (like "System.Xml"). If the reference /// type is "Project" this will be the name of the project. /// If the type is "Guid", we construct the Interop assembly name</value> public string Value { get { string result = null; switch (Type) { case "AssemblyName": result = (string)_Navigator.Evaluate("string(@AssemblyName)"); break; case "Project": Project project = _Solution.GetProject( new Guid((string)_Navigator.Evaluate("string(@Project)"))); if (project != null) { result = project.Name; } break; case "Guid": // COM interop result = "Interop." + (string)_Navigator.Evaluate("string(@Name)"); break; } return result; } } } } --- NEW FILE: SLiNgshoT.Core.csproj --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.0.9466" SchemaVersion = "1.0" ProjectGuid = "{3F533CCA-9C8F-4D84-8C1A-1F6D89CB5912}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "SLiNgshoT.Core" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" RootNamespace = "SLiNgshoT.Core" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "true" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.dll" /> <Reference Name = "System.Data" AssemblyName = "System.Data" HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Data.dll" /> <Reference Name = "System.XML" AssemblyName = "System.Xml" HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Attributes.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Configuration.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Driver.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "File.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NAntWriter.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NMakeWriter.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Project.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Reference.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Solution.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "SolutionWriter.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> --- NEW FILE: Solution.cs --- // Solution.cs - the Solution class // Copyright (C) 2001, 2002 Jason Diamond // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Collections; using System.IO; using System.Text.RegularExpressions; using System.Xml; using System.Xml.XPath; namespace SLiNgshoT.Core { /// <summary>Represents a VS.NET solution.</summary> public class Solution { private string _SolutionDirectory; /// <summary>Gets the SolutionDirectory property.</summary> /// <remarks>This is the directory that contains the VS.NET /// solution file.</remarks> public string SolutionDirectory { get { return _SolutionDirectory; } } private string _SolutionName; /// <summary>Gets the SolutionName property.</summary> /// <remarks>This is the name of the VS.NET solution file /// without the .sln extension.</remarks> public string SolutionName { get { return _SolutionName; } } private Hashtable _UriMap; /// <summary>Reads a .sln file.</summary> /// <param name="path">The path to the .sln file.</param> /// <param name="uriPrefix"></param> /// <param name="filePrefix"></param> public void Read(string path, Hashtable uriMap) { _UriMap = uriMap; path = Path.GetFullPath(path); _SolutionDirectory = Path.GetDirectoryName(path); _SolutionName = Path.GetFileNameWithoutExtension(path); StreamReader streamReader = null; try { streamReader = new StreamReader(path); string line = streamReader.ReadLine(); if (line != "Microsoft Visual Studio Solution File, Format Version 7.00") { throw new ApplicationException("this is not a 'Microsoft Visual Studio Solution File, Format Version 7.00' file"); } bool projectDependencies = false; while ((line = streamReader.ReadLine()) != null) { if (line.StartsWith("Project")) { AddProject(line); } else if (line.StartsWith("\tGlobalSection(ProjectDependencies)")) { projectDependencies = true; } else if (projectDependencies && line.StartsWith("\tEndGlobalSection")) { projectDependencies = false; } else if (projectDependencies) { AddDependency(line); } } } finally { if (streamReader != null) { streamReader.Close(); } } } private Hashtable _Projects = new Hashtable(); private void AddProject(string projectLine) { string pattern = @"^Project\(""(?<unknown>\S+)""\) = ""(?<name>\S+)"", ""(?<path>\S+)"", ""(?<id>\S+)"""; Regex regex = new Regex(pattern); Match match = regex.Match(projectLine); if (match.Success) { string unknown = match.Groups["unknown"].Value; string name = match.Groups["name"].Value; string path = match.Groups["path"].Value; string id = match.Groups["id"].Value; path = ResolvePath(path); Project project = new Project(this, new Guid(id), name); string absoluteProjectPath = Path.Combine(SolutionDirectory, path); project.Read(absoluteProjectPath); string relativeProjectPath = Path.GetDirectoryName(path); project.RelativePath = relativeProjectPath; if (project.ProjectType == "C# Local" || project.ProjectType == "C# Web") { _Projects.Add(project.ID, project); } } } private string ResolvePath(string path) { if (path.StartsWith("http:")) { if (_UriMap != null) { foreach (DictionaryEntry entry in _UriMap) { if (path.StartsWith((string)entry.Key)) { return entry.Value + path.Substring(((string)entry.Key).Length); } } } throw new ApplicationException("a prefix mapping needs to be specified for " + path); } return path; } private void AddDependency(string dependencyLine) { string pattern = @"^\t\t(?<source>\S+).\d+ = (?<target>\S+)"; Regex regex = new Regex(pattern); Match match = regex.Match(dependencyLine); if (match.Success) { string source = match.Groups["source"].Value; string target = match.Groups["target"].Value; Project sourceProject = _Projects[new Guid(source)] as Project; Project targetProject = _Projects[new Guid(target)] as Project; if (sourceProject != null && targetProject != null) { AddDependency(sourceProject, targetProject); } } } private Hashtable _Dependencies = new Hashtable(); private void AddDependency(Project source, Project target) { ArrayList dependencies = _D... [truncated message content] |