// 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.Generic;
using System.IO;
using System.Xml;
namespace Rauchy.Regionerate.ServiceLayer.Components.Projects
{
///
/// Provides access to the names of the compiled files in a C# project file.
///
public class CSharpProject : Project
{
#region Fields (1)
private readonly string _projectPath;
#endregion
#region Constructors (1)
///
/// Initializes a new instance of the class.
///
/// The path.
public CSharpProject( string path ) : base( path )
{
_projectPath = path;
}
#endregion
#region Methods (1)
public override IEnumerator GetEnumerator()
{
string projectDirectory = Path.GetDirectoryName( _projectPath );
XmlNamespaceManager namespaceManager = new XmlNamespaceManager( ProjectFile.NameTable );
string namespaceUri = "http://schemas.microsoft.com/developer/msbuild/2003";
namespaceManager.AddNamespace( "ms", namespaceUri );
string query = "ms:Project/ms:ItemGroup/ms:Compile/@Include";
XmlNodeList nodes = ProjectFile.SelectNodes( query, namespaceManager );
foreach ( XmlNode node in nodes )
{
string fileName = node.Value;
string filePath = Path.Combine( projectDirectory, fileName );
Document document = new FileDocument( filePath );
yield return document;
}
}
#endregion
}
}