public Amqp Queue(string queue) { if (!Queues.Contains(queue)) { Queues.Add(queue); } return(new Amqp(this, queue)); }
private bool ShouldSkip() { if (Queues == null) { return(true); } var targetQueue = GetTargetHelixQueue().ToLowerInvariant(); if (Queues.Contains("All.OSX") && targetQueue.StartsWith("osx")) { return(true); } return(Queues.ToLowerInvariant().Split(';').Contains(targetQueue)); }
private bool ShouldSkip() { if (Queues == null) { return(true); } var targetQueue = GetTargetHelixQueue().ToLowerInvariant(); if (Queues.Contains("All.OSX") && targetQueue.StartsWith("osx", StringComparison.OrdinalIgnoreCase)) { return(true); } if (Queues.Contains("All.Ubuntu") && targetQueue.StartsWith("ubuntu", StringComparison.OrdinalIgnoreCase)) { return(true); } return(Queues.ToLowerInvariant().Split(';').Contains(targetQueue)); }
public Configuration() { //Queues settings try { Queues = ConfigurationManager.AppSettings[_queueConfigKey] .Split(_queueConfigSectionSeparator) .Select(p => p.Split(_queueConfigParamsSeparator)) .Select(sp => sp[_queuesConfigIndex]) .ToList(); QueuesDescriptions = ConfigurationManager.AppSettings[_queueConfigKey] .Split(_queueConfigSectionSeparator) .Select(p => p.Split(_queueConfigParamsSeparator)) .ToDictionary(sp => sp[_queuesConfigIndex], sp => sp[_queueConfigDescriptionIndex]); //QueuesLocalWeights = ConfigurationManager.AppSettings[_queueConfigKey] // .Split(_queueConfigSectionSeparator) // .Select(p => p.Split(_queueConfigParamsSeparator)) // .ToDictionary(sp => sp[_queuesConfigIndex], sp => int.Parse(sp[_queueConfigLocalWeightIndex])); } catch (Exception e) { throw new ConfigurationErrorsException("Coudln't load Queues settings", e); } if (Queues == null || Queues.Count == 0 || Queues.Contains(string.Empty)) { throw new ConfigurationErrorsException("Queue configuration is invalid"); } // Server settings try { Server = ConfigurationManager.AppSettings["Server"]; ServerPort = int.Parse(ConfigurationManager.AppSettings["ServerPort"]); Username = ConfigurationManager.AppSettings["Username"]; Password = ConfigurationManager.AppSettings["Password"]; } catch (Exception e) { throw new ConfigurationErrorsException("Coudln't load Server settings", e); } // Application settings try { PopupOnNewCall = bool.Parse(ConfigurationManager.AppSettings["PopupOnNewCall"]); AlwaysOnTop = bool.Parse(ConfigurationManager.AppSettings["AlwaysOnTop"]); PollInterval = int.Parse(ConfigurationManager.AppSettings["PollInterval"]); StartAutoPollOnStartup = bool.Parse(ConfigurationManager.AppSettings["StartAutoPollOnStartup"]); HightlightRowIfQueueNotEmpty = bool.Parse(ConfigurationManager.AppSettings["HightlightRowIfQueueNotEmpty"]); DateTimeFormat = ConfigurationManager.AppSettings["DateTimeFormat"]; } catch (Exception e) { throw new ConfigurationErrorsException("Coudln't load Application settings", e); } // Style settings try { WindowTitle = ConfigurationManager.AppSettings["WindowTitle"]; var fontConverter = new FontConverter(); ConsoleFont = fontConverter.ConvertFromString(ConfigurationManager.AppSettings["ConsoleFont"]) as Font; TableHeadersFont = fontConverter.ConvertFromString(ConfigurationManager.AppSettings["TableHeadersFont"]) as Font; TableRowsFont = fontConverter.ConvertFromString(ConfigurationManager.AppSettings["TableRowsFont"]) as Font; StateIndicatorsFont = fontConverter.ConvertFromString(ConfigurationManager.AppSettings["StateIndicatorsFont"]) as Font; TableHeadersHeight = int.Parse(ConfigurationManager.AppSettings["TableHeadersHeight"]); FormOrigin = (Point) new PointConverter().ConvertFromString(ConfigurationManager.AppSettings["FormOrigin"]); FormSize = (Size) new SizeConverter().ConvertFromString(ConfigurationManager.AppSettings["FormSize"]); ConsoleSplitterRatio = float.Parse(ConfigurationManager.AppSettings["ConsoleSplitterRatio"]); QueuesSplitterRatio = float.Parse(ConfigurationManager.AppSettings["QueuesSplitterRatio"]); TableHeadersColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["TableHeadersColor"]); TableGridsColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["TableGridsColor"]); ConsoleAreaColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["ConsoleAreaColor"]); QueuesAreaColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["QueuesAreaColor"]); TableHeadersTextColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["TableHeadersTextColor"]); TableRowsTextColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["TableRowsTextColor"]); ConsoleInfoTextColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["ConsoleInfoTextColor"]); ConsoleErrorTextColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["ConsoleErrorTextColor"]); HighlightRowColor = ColorTranslator.FromHtml(ConfigurationManager.AppSettings["HighlightRowColor"]); } catch (Exception e) { throw new ConfigurationErrorsException("Coudln't load Style settings", e); } }
/// <summary> /// Deserializes the specified <see cref="System.Xml.XmlDocument">XmlDocument</see>. /// </summary> /// <param name="ccnetConfig">The ccnet config.</param> /// <exception cref="CCNetConfig.Core.Exceptions.DuplicateProjectNameException">DuplicateProjectNameException</exception> public void Deserialize(XmlDocument ccnetConfig) { this.Projects.Clear(); Queues.Clear(); Version v = Util.GetConfigFileVersion(ccnetConfig); if (v != null) { this.Version = v; } if (ccnetConfig.DocumentElement != null && string.Compare(ccnetConfig.DocumentElement.Name, "cruisecontrol", false) == 0) { /*this.Entities = ccnetConfig.DocumentType.Entities; * foreach ( XmlEntity entity in this.Entities ) { * Console.WriteLine ( entity.ToString () ); * }*/ ItemSerialiserFactory factory = new ItemSerialiserFactory(); // Attempt to deserialise each item in the configuration foreach (XmlElement item in ccnetConfig.DocumentElement.SelectNodes("*")) { IItemSerialiser serialiser = factory.Retrieve(item.Name); if (serialiser != null) { // The serialiser factory knows the item type, so it can be deserialised and // added to the correct collection object output = serialiser.Deserialize(item); if (output is Project) { Project p = output as Project; if (!this.Projects.Contains(p.Name)) { this.Projects.Add(p); } else { throw new DuplicateProjectNameException(p.Name); } } else if (output is Queue) { Queue q = output as Queue; if (!Queues.Contains(q.Name)) { Queues.Add(q); } else { throw new Exception(string.Format("Duplicate queue definition: '{0}'", q.Name)); } } else if (output is ServerSecurity) { Security = output as ServerSecurity; } } else { // Currently throwing an exception if an unhandled item is found // This should be changed to something a bit nicer throw new Exception( string.Format("Unhandled item found: '{0}'", item.Name)); } } if (Util.UserSettings.SortProject) { this.Projects.Sort(new ProjectList.ProjectComparer()); } // Check all the projects and add any explicit queues that don't have their own configuration foreach (Project p in Projects) { if (!string.IsNullOrEmpty(p.Queue)) { if (!Queues.Contains(p.Queue)) { Queue queue = new Queue(); queue.Name = p.Queue; Queues.Add(queue); } Queues[p.Queue].Projects.Add(p); } } } else { throw new InvalidCastException(string.Format("Can not convert {0} to a cruisecontrol", ccnetConfig.DocumentElement != null ? ccnetConfig.DocumentElement.Name : "UNKNOWN")); } }