Skip to content

Commit

Permalink
Merge pull request #811 from 304NotModified/easier-api
Browse files Browse the repository at this point in the history
Easier API
  • Loading branch information
304NotModified committed Aug 7, 2015
2 parents 5a1b7b4 + 693f0a2 commit 5b0ad13
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/NLog/Config/LoggingConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ public ReadOnlyCollection<Target> AllTargets
get { return this.configItems.OfType<Target>().ToList().AsReadOnly(); }
}

/// <summary>
/// Registers the specified target object. The name of the target is read from <see cref="Target.Name"/>.
/// </summary>
/// <param name="target">
/// The target object with a non <see langword="null"/> <see cref="Target.Name"/>
/// </param>
/// <exception cref="ArgumentNullException">when <paramref name="target"/> is <see langword="null"/></exception>
public void AddTarget([NotNull] Target target)
{
if (target == null) throw new ArgumentNullException("target");
AddTarget(target.Name, target);
}

/// <summary>
/// Registers the specified target object under a given name.
/// </summary>
Expand Down Expand Up @@ -166,6 +179,22 @@ public Target FindTargetByName(string name)
return value;
}

/// <summary>
/// Finds the target with the specified name and specified type.
/// </summary>
/// <param name="name">
/// The name of the target to be found.
/// </param>
/// <typeparam name="TTarget">Type of the target</typeparam>
/// <returns>
/// Found target or <see langword="null"/> when the target is not found of not of type <typeparamref name="TTarget"/>
/// </returns>
public TTarget FindTargetByName<TTarget>(string name)
where TTarget : Target
{
return FindTargetByName(name) as TTarget;
}

/// <summary>
/// Called by LogManager when one of the log configuration files changes.
/// </summary>
Expand Down

0 comments on commit 5b0ad13

Please sign in to comment.