/// <summary> /// Initialize a new <see cref="LocalJudgeNodeManager"/> instance. /// </summary> /// <param name="options">The options.</param> /// <exception cref="ArgumentNullException"><paramref name="options"/> is null.</exception> public LocalJudgeNodeManager(JudgeNodeManagerOptions options) { Contract.NotNull(options, nameof(options)); _options = options; _store = new Dictionary <IPAddress, JudgeNodeInfo>(); }
/// <summary> /// Add <see cref="LocalJudgeNodeManager"/> as the desired implementation of <see cref="IJudgeNodeManager"/> /// into the given service collection. /// </summary> /// <param name="services">The service collection.</param> /// <param name="optionCallback">The callback for configuring options.</param> /// <exception cref="ArgumentNullException"><paramref name="services"/> is null.</exception> public static IServiceCollection AddLocalJudgeNodeManager(this IServiceCollection services, Action <JudgeNodeManagerOptions> optionCallback = null) { Contract.NotNull(services, nameof(services)); var options = new JudgeNodeManagerOptions(); optionCallback?.Invoke(options); return(services.AddSingleton(options) .AddSingleton <IJudgeNodeManager, LocalJudgeNodeManager>()); }