// Copyright 2004-2009 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. namespace Castle.MonoRail.Framework { using System; /// /// Represents the tokenized information from an Url. /// [Serializable] public class UrlInfo { private readonly int port; private readonly string domain, subdomain, appVirtualDir, protocol; private readonly string urlRaw; private readonly string area, controller, action, extension; private readonly string pathInfo; /// /// Initializes a new instance of the class. /// /// The area. /// The controller. /// The action. public UrlInfo(string area, string controller, string action) { this.area = area; this.controller = controller; this.action = action; } /// /// Initializes a new instance of the class. /// /// The area. /// The controller. /// The action. /// The app virtual dir. /// The extension. public UrlInfo(string area, string controller, string action, string appVirtualDir, string extension) { this.area = area; this.controller = controller; this.action = action; this.appVirtualDir = appVirtualDir; this.extension = extension; } /// /// Initializes a new instance of the class. /// /// The domain (host). /// The subdomain (first token on the domain). /// The application virtual dir. /// Protocol (http/https) /// The port. /// The raw URL. /// The area, or empty. /// The controller name. /// The action name. /// The file extension. /// The path info. public UrlInfo(string domain, string subdomain, string appVirtualDir, string protocol, int port, string urlRaw, string area, string controller, string action, string extension, string pathInfo) { this.port = port; this.domain = domain; this.subdomain = subdomain; this.urlRaw = urlRaw; this.area = area; this.controller = controller; this.action = action; this.extension = extension; this.pathInfo = pathInfo; this.appVirtualDir = appVirtualDir; this.protocol = protocol; } /// /// Gets the app virtual dir. /// /// The app virtual dir. public string AppVirtualDir { get { return appVirtualDir; } } /// /// Gets the port. /// /// The port. public int Port { get { return port; } } /// /// Gets the domain. /// /// The domain. public string Domain { get { return domain; } } /// /// Gets the subdomain. /// /// The subdomain. public string Subdomain { get { return subdomain; } } /// /// Gets the subdomain. /// /// The subdomain. public string FullDomain { get { if (!string.IsNullOrEmpty(subdomain)) return subdomain + "." + domain; else return domain; } } /// /// Gets the URL raw. /// /// The URL raw. public string UrlRaw { get { return urlRaw; } } /// /// Gets the area. /// /// The area. public string Area { get { return area; } } /// /// Gets the controller. /// /// The controller. public string Controller { get { return controller; } } /// /// Gets the action. /// /// The action. public string Action { get { return action; } } /// /// Gets the protocol. /// /// The protocol. public string Protocol { get { return protocol; } } /// /// The URL extension, without the leading dot. /// public string Extension { get { return extension; } } /// /// Gets the path info. /// /// The path info. public string PathInfo { get { return pathInfo; } } } }