// NAnt - A .NET build tool // Copyright (C) 2001-2002 Gerry Shaw // // 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.Specialized; using System.IO; using NAnt.Core; using NAnt.Core.Types; using NAnt.Core.Attributes; using NAnt.VSNet.Attributes; namespace NAnt.VSNet.Types { /// /// Manages a list of mappings between web project URLs and physical disk paths. /// /// [ElementName("webmap")] public class WebMap : DataTypeBase { private HybridDictionary _webMap = new HybridDictionary(); /// /// Construct a WebMap. /// public WebMap() { } /// /// Return the mapped path of the given path. If the web map is empty or no match is found, /// the path itself will be returned. /// public string this[string path] { get { string mappedPath = (string)_webMap[path]; if (mappedPath == null) { return path; } else { return mappedPath; } } } /// /// Get the map elements. /// [BuildElementArray("map")] public WebMapElement[] SetMap { set { foreach (WebMapElement webMapElement in value) { _webMap.Add(webMapElement.Url, webMapElement.Path); Console.WriteLine("[solution] Mapping Project {0} to {1}", webMapElement.Url, webMapElement.Path); } } } } /// /// Represents a single mapping from URL project path to physical project path. /// public class WebMapElement : Element { private string _strUrl, _strPath; /// /// The URL of the project file. /// [TaskAttribute("url", Required=true)] public string Url { get { return _strUrl; } set { _strUrl = value; } } /// /// The actual path to the project file. /// [TaskAttribute("path", Required=true)] public string Path { get { return _strPath; } set { _strPath = value; } } } }