// Copyright (c) 2007 Omer Rauchwerger (a.k.a rauchy) (omer@rauchy.net) // All rights reserved. // // This file is part of Regionerate. // // 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 3 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, see . using System.Collections; using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; using Rauchy.Regionerate.ServiceLayer.Components.Projects; namespace Rauchy.Regionerate.ServiceLayer.Components { /// /// Provides access to the object in a Visual Studio solution file. /// public class Solution : IEnumerable { #region Fields (1)  private readonly IList _projects; #endregion Fields  #region Constructors (1)  /// /// Initializes a new instance of the class. /// /// The solution file path. public Solution( string path ) { Regex regex = new Regex( ".*\\\"(?.*?\\.csproj)\\\"" ); string text = File.ReadAllText( path ); Match match = regex.Match( text ); string solutionDirectory = Path.GetDirectoryName( path ); _projects = new List(); while ( match.Success ) { string projectName = match.Groups[ "ProjectPath" ].Value; string projectPath = Path.Combine( solutionDirectory, projectName ); Project project = new CSharpProject( projectPath ); _projects.Add( project ); match = match.NextMatch(); } } #endregion Constructors  #region Methods (2)  // Public Methods (1)  /// ///Returns an enumerator that iterates through the collection. /// /// /// ///A that can be used to iterate through the collection. /// ///1 public IEnumerator GetEnumerator() { return _projects.GetEnumerator(); } // Private Methods (1)  /// ///Returns an enumerator that iterates through a collection. /// /// /// ///An object that can be used to iterate through the collection. /// ///2 IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } #endregion Methods  } }