/// <summary> /// Adds the elements of another TargetCollection to the end of this TargetCollection. /// </summary> /// <param name="items"> /// The TargetCollection whose elements are to be added to the end of this TargetCollection. /// </param> public virtual void AddRange(TargetCollection items) { foreach (Target item in items) { this.List.Add(item); } }
/// <summary> /// /// </summary> /// <param name="collection"></param> public Enumerator(TargetCollection collection) { this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator(); }
/// <summary> /// Initializes a new instance of the TargetCollection class, containing elements /// copied from another instance of TargetCollection /// </summary> /// <param name="items"> /// The TargetCollection whose elements are to be added to the new TargetCollection. /// </param> public TargetCollection(TargetCollection items) { this.AddRange(items); }
/// <summary> /// Returns a collection of named targets specified in the configuration. /// </summary> /// <returns>A <see cref="TargetCollection"/> object that contains a list of named targets.</returns> /// <remarks> /// Unnamed targets (such as those wrapped by other targets) are not returned. /// </remarks> public TargetCollection GetConfiguredNamedTargets() { TargetCollection tc = new TargetCollection(); foreach (Target t in _targets.Values) { tc.Add(t); } return tc; }
private void ReloadTargets() { TargetCollection tmp = new TargetCollection(); using (SqlConnection reposConn = new SqlConnection(GetReposConnectionString("Manager"))) { reposConn.Open(); using (SqlCommand reposCmd = reposConn.CreateCommand()) { reposCmd.CommandText = "SELECT Id, ServerName, IsSqlAuthentication, Username, Password FROM dbo.Targets ORDER BY Id"; reposCmd.CommandType = CommandType.Text; using (SqlDataReader reposReader = reposCmd.ExecuteReader()) { while (reposReader.Read()) { tmp.Add( (int)reposReader["Id"], new Target( (int)reposReader["Id"], reposReader["ServerName"].ToString(), (bool)reposReader["IsSqlAuthentication"], reposReader["Username"].ToString(), reposReader["Password"].ToString() ) ); } reposReader.Close(); } } reposConn.Close(); } targets = tmp; }