AvalonStudio.Projects.Solution.Load C# (CSharp) Method

Load() public static method

public static Load ( string fileName ) : Solution
fileName string
return Solution
		public static Solution Load(string fileName)
		{
			var solution = SerializedObject.Deserialize<Solution>(fileName);

			solution.CurrentDirectory = (Path.GetDirectoryName(fileName) + Platform.DirectorySeperator).ToPlatformPath();

			Console.WriteLine("Solution directory is " + solution.CurrentDirectory);

			foreach (var projectReference in solution.ProjectReferences)
			{
				var proj = LoadProject(solution, projectReference);

				// todo null returned here we need a placeholder.
				if (proj != null)
				{
					solution.Projects.InsertSorted(proj);
				}
			}

			foreach (var project in solution.Projects)
			{
				project.ResolveReferences();
                project?.ToolChain?.ProvisionSettings(project);
            }

			solution.Name = Path.GetFileNameWithoutExtension(fileName);

			solution.StartupProject = solution.Projects.SingleOrDefault(p => p.Name == solution.StartupItem);

			return solution;
		}

Usage Example

 public async Task <ISolution> LoadAsync(string path)
 {
     return(await Task.Factory.StartNew(() => { return Solution.Load(path); }));
 }