/* * public Assembly[] LoadReferencedAssemblies(List<CompileResult> compiled) * { * List<Assembly> result = new List<Assembly>(); * foreach (var i in reference) * { * // todo:use Application domain instead of Assembly.Load * var aa = Assembly.LoadWithPartialName(i); * result.Add(aa); * } * foreach (var projectReference in ProjectReferences) * { * var compiledProject = compiled.Where(i => i.ProjectGuid == projectReference.ProjectGuid).First(); * result.Add(compiledProject.CompiledAssembly); * } * * * return result.ToArray(); * } */ #region Static Methods // Public Methods public static Project1 Load(string filename) { var project = new Project1 { _workingDirectory = new FileInfo(filename).Directory }; var doc = XDocument.Load(filename); var docRoot = doc.Root; if (docRoot == null) { return(project); } var ns = docRoot.Name.Namespace; foreach (var i in docRoot.Elements(ns + "PropertyGroup")) { project.ParsePropertyGroup(i); } var itemGroups = docRoot.Elements(ns + "ItemGroup").ToArray(); foreach (var ig in itemGroups) { /* * <Reference Include="System" /> * <Reference Include="System.Core" /> * <Reference Include="System.Xml.Linq" /> * <Reference Include="System.Data.DataSetExtensions" /> * <Reference Include="Microsoft.CSharp" /> * <Reference Include="System.Data" /> * <Reference Include="System.Xml" /> */ foreach (var i in ig.Elements()) { if (i.Name == ns + "Reference") { project._reference.Add((string)i.Attribute("Include")); } else if (i.Name == ns + "Compile") { var name = (string)i.Attribute("Include"); var pi = new ProjectItem(name, BuildActions.Compile); project._items.Add(pi); } else if (i.Name == ns + "ProjectReference") { var g = ProjectReference.Deserialize(i); project._projectReferences.Add(g); } else if (i.Name == ns + "Content") { var name = (string)i.Attribute("Include"); var pi = new ProjectItem(name, BuildActions.Content); project._items.Add(pi); } } } return(project); }
/* public Assembly[] LoadReferencedAssemblies(List<CompileResult> compiled) { List<Assembly> result = new List<Assembly>(); foreach (var i in reference) { // todo:use Application domain instead of Assembly.Load var aa = Assembly.LoadWithPartialName(i); result.Add(aa); } foreach (var projectReference in ProjectReferences) { var compiledProject = compiled.Where(i => i.ProjectGuid == projectReference.ProjectGuid).First(); result.Add(compiledProject.CompiledAssembly); } return result.ToArray(); } */ #region Static Methods // Public Methods public static Project1 Load(string filename) { var project = new Project1 { _workingDirectory = new FileInfo(filename).Directory }; var doc = XDocument.Load(filename); var docRoot = doc.Root; if (docRoot == null) return project; var ns = docRoot.Name.Namespace; foreach (var i in docRoot.Elements(ns + "PropertyGroup")) project.ParsePropertyGroup(i); var itemGroups = docRoot.Elements(ns + "ItemGroup").ToArray(); foreach (var ig in itemGroups) { /* * <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> */ foreach (var i in ig.Elements()) { if (i.Name == ns + "Reference") { project._reference.Add((string)i.Attribute("Include")); } else if (i.Name == ns + "Compile") { var name = (string)i.Attribute("Include"); var pi = new ProjectItem(name, BuildActions.Compile); project._items.Add(pi); } else if (i.Name == ns + "ProjectReference") { var g = ProjectReference.Deserialize(i); project._projectReferences.Add(g); } else if (i.Name == ns + "Content") { var name = (string)i.Attribute("Include"); var pi = new ProjectItem(name, BuildActions.Content); project._items.Add(pi); } } } return project; }