BuildServer.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » CCTrayLib » Configuration » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » CCTrayLib » Configuration » BuildServer.cs
using System;
using ThoughtWorks.CruiseControl.Remote;

namespace ThoughtWorks.CruiseControl.CCTrayLib.Configuration{
  public class BuildServer
  {
    private const int DefaultRemotingPort = 21234;

    private string url;
        private BuildServerTransport transportMode = BuildServerTransport.HTTP;
        private string extensionName;
        private string settings;
        private string securityType;
        private string securitySettings;

    public BuildServer()
    {
    }
      
        public BuildServer(string url)
        {
            this.url = url;
            Uri serverUri = new Uri(Url);
            this.transportMode = (serverUri.Scheme.ToLower() == "tcp") ? BuildServerTransport.Remoting : BuildServerTransport.HTTP;
    }
    
        /// <summary>
        /// Start a new build server using the full options.
        /// </summary>
        /// <param name="url">The URI to the remote server.</param>
        /// <param name="transportMode">The transport mode to use.</param>
        /// <param name="extensionName">The name of the extension to use.</param>
        /// <param name="settings">The settings for the extension.</param>
        public BuildServer(string url, BuildServerTransport transportMode, string extensionName, string settings)
        {
            if ((transportMode == BuildServerTransport.Extension) && string.IsNullOrEmpty(extensionName))
            {
                throw new CCTrayLibException("Extension transport must always define an extension name");
            }
            this.url = url;
            this.transportMode = transportMode;
            this.extensionName = extensionName;
            this.settings = settings;
        }

    public string Url
    {
      get { return url; }
    }
    
    public Uri Uri
    {
      get { return new Uri(url); }
    }

        public string ExtensionName
        {
            get { return this.extensionName; }
            set { this.extensionName = value; }
        }

        public string ExtensionSettings
        {
            get { return this.settings; }
            set { this.settings = value; }
        }

        public string SecurityType
        {
            get { return this.securityType; }
            set { this.securityType = value; }
        }

        public string SecuritySettings
        {
            get { return this.securitySettings; }
            set { this.securitySettings = value; }
        }

    public string DisplayName
    {
      get 
      {
        if (Transport == BuildServerTransport.Remoting)
        {
          Uri serverUri = Uri;
          if (serverUri.Port == DefaultRemotingPort)
            return serverUri.Host;

          return serverUri.Host + ":" + serverUri.Port;
        }
        
        return Url;
      }
    }

    public BuildServerTransport Transport
    {
            get { return this.transportMode; }
            set { this.transportMode = value; }
    }

    public static BuildServer BuildFromRemotingDisplayName(string displayName)
    {
      string url;
      
      string[] displayNameParts = displayName.Split(':');

      if (displayNameParts.Length == 1)
      {
        url = string.Format("tcp://{0}:{1}/CruiseManager.rem", displayNameParts[0], DefaultRemotingPort);
      }
      else if (displayNameParts.Length == 2)
      {
        try
        {
          url =
            string.Format("tcp://{0}:{1}/CruiseManager.rem", displayNameParts[0], Convert.ToInt32(displayNameParts[1]));
        }
        catch (FormatException)
        {
          throw new ApplicationException("Port number must be an integer");
        }
      }
      else
      {
        throw new ApplicationException("Expected string in format server[:port]");
      }
      return new BuildServer(url, BuildServerTransport.Remoting, null, null);
    }
    
    public override bool Equals(object obj)
    {
      BuildServer other = obj as BuildServer;
      if (other == null)
        return false;
      
      return other.url.Equals (url);
    }

    public override int GetHashCode()
    {
      return url.GetHashCode ();
    }

    public override string ToString()
    {
      return DisplayName;
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.