public Exercise(ILoggerService loggerService, ISpeechService speechService, string name, int setCount, int repetitionCount, IEnumerable<MatcherWithAction> matchersWithActions) { loggerService.AssertNotNull(nameof(loggerService)); speechService.AssertNotNull(nameof(speechService)); name.AssertNotNull(nameof(name)); matchersWithActions.AssertNotNull(nameof(matchersWithActions)); if (setCount < 0) { throw new ArgumentException("setCount cannot be less than zero.", "setCount"); } if (repetitionCount < 0) { throw new ArgumentException("repetitionCount cannot be less than zero.", "repetitionCount"); } this.logger = loggerService.GetLogger(this.GetType()); this.speechService = speechService; this.name = name; this.setCount = setCount; this.repetitionCount = repetitionCount; this.matchersWithActions = matchersWithActions.ToImmutableList(); using (var dummyExecutionContext = new ExecutionContext()) { this.duration = this .GetEventsWithActions(dummyExecutionContext) .SelectMany(x => x.Actions) .Select(x => x.Duration) .DefaultIfEmpty() .Aggregate((running, next) => running + next); } }
/// <summary> /// Asynchronously writes a record to this <c>CsvWriter</c>. /// </summary> /// <remarks> /// None of the <see cref="System.String"/>s within <paramref name="values"/> can be <see langword="null"/>. If so, an exception will be thrown. /// </remarks> /// <param name="values"> /// The values comprising the record. /// </param> /// <returns> /// A <see cref="Task"/> representing the asynchronous operation. /// </returns> public async Task WriteRecordAsync(IEnumerable<string> values) { Debug.Assert(this.bufferBuilder.Length == 0, "Expecting buffer to be empty."); this.EnsureNotDisposed(); values.AssertNotNull("values"); this.WriteRecordToBuffer(values); await this.FlushBufferToTextWriterAsync().ConfigureAwait(false); }
public MetronomeAction(IAudioService audioService, IDelayService delayService, ILoggerService loggerService, IEnumerable<MetronomeTick> ticks) { audioService.AssertNotNull(nameof(audioService)); delayService.AssertNotNull(nameof(delayService)); loggerService.AssertNotNull(nameof(loggerService)); ticks.AssertNotNull(nameof(ticks)); this.ticks = ticks.ToImmutableList(); this.innerAction = new SequenceAction(GetInnerActions(audioService, delayService, loggerService, this.ticks)); }
/// <summary> /// Creates a new NetNode with the specified fields. /// </summary> /// <param name="guid">The unique Id for the computer.</param> /// <param name="name">The user friendly name for the computer.</param> /// <param name="uri">The computer's Uri, if it has one.</param> /// <param name="edges">Edges from this computer to others.</param> public NetNode(Guid guid, string name, Uri uri, IEnumerable<INetEdge> edges) { guid.AssertNotNull(nameof(guid)); name.AssertNotNullOrEmptyOrWhitespace(nameof(name)); edges.AssertNotNull(nameof(edges)); this.guid = guid; this.name = name; this.edges = edges.ToImmutableDictionary(edge => edge.Destination.Guid, edge => edge); }
public SequenceAction(IEnumerable<IAction> children) { children.AssertNotNull(nameof(children), assertContentsNotNull: true); this.children = children.ToImmutableList(); this.duration = this .children .Select(x => x.Duration) .DefaultIfEmpty() .Aggregate((running, next) => running + next); }
public ParallelAction(IEnumerable<IAction> children) { children.AssertNotNull(nameof(children), assertContentsNotNull: true); this.children = children.ToImmutableList(); this.duration = this .children .Select(x => x.Duration) .DefaultIfEmpty() .Max(); }
/// <summary> /// Creates a new NetGraph representation from raw data. /// </summary> /// <param name="nodes"> /// A list of all nodes. The first node is assumed to be this computer. /// </param> private NetGraph(IEnumerable<INetNode> nodes) { nodes.AssertNotNull(nameof(nodes)); if (nodes.FirstOrDefault() != null) { this.thisNode = nodes.First(); } this.nodes = nodes.ToImmutableDictionary(edge => edge.Guid, edge => edge); }
public IRace Create(IDistanceCalculator distanceCalculator, IEnumerable<Waypoint> waypoints) { distanceCalculator.AssertNotNull(); waypoints = waypoints as List<Waypoint> ?? waypoints.ToList(); waypoints.AssertNotEmpty(); waypoints.AssertNotNull(); var Race = new RaceService(distanceCalculator, waypoints); return Race; }
/// <summary> /// Determines whether the principal contains the specified claim types. /// </summary> /// <param name="principal">The principal.</param> /// <param name="claimTypes">The claim types.</param> /// <returns> /// <c>true</c> if the principal contains the specified claim types; otherwise, <c>false</c>. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="claimTypes"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentException"> /// One of the items in the <paramref name="claimTypes"/> collection is <see langword="null"/>. /// </exception> public static bool HasClaimTypes(this ClaimsPrincipal principal, IEnumerable<string> claimTypes) { claimTypes.AssertNotNull(true, "claimTypes"); foreach (var type in claimTypes) { if (!principal.HasClaim(c => c.Type == type)) { return false; } } return true; }
/// <summary> /// Determines whether the principal contains the specified claims. /// </summary> /// <param name="principal">The principal.</param> /// <param name="claims">The claims.</param> /// <returns><c>true</c> if the principal contains the specified claims; otherwise, <c>false</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="claims"/> is <see langword="null"/>.</exception> /// <exception cref="ArgumentException"> /// One of the items in the <paramref name="claims"/> collection is <see langword="null"/>. /// </exception> public static bool HasClaims(this ClaimsPrincipal principal, IEnumerable<Claim> claims) { claims.AssertNotNull(true, "claims"); foreach (var claim in claims) { if (!principal.HasClaim(claim.Type, claim.Value)) { return false; } } return true; }
public ExerciseProgram(ILoggerService loggerService, string name, IEnumerable<Exercise> exercises) { loggerService.AssertNotNull(nameof(loggerService)); name.AssertNotNull(nameof(name)); exercises.AssertNotNull(nameof(exercises), assertContentsNotNull: true); this.logger = loggerService.GetLogger(this.GetType()); this.name = name; this.exercises = exercises.ToImmutableList(); this.duration = this .exercises .Select(x => x.Duration) .DefaultIfEmpty() .Aggregate((running, next) => running + next); }
/// <summary> /// Writes a record to this <c>CsvWriter</c>. /// </summary> /// <remarks> /// Any <see langword="null"/> values will be written as empty strings. /// </remarks> /// <param name="values"> /// The values comprising the record. /// </param> public void WriteRecord(IEnumerable<string> values) { Debug.Assert(this.bufferBuilder.Length == 0, "Expecting buffer to be empty."); this.EnsureNotDisposed(); values.AssertNotNull("values"); this.WriteRecordToBuffer(values); this.FlushBufferToTextWriter(); }
/// <summary> /// Initializes a new instance of the HeaderRecord class. /// </summary> /// <param name="columnNames"> /// The names of the columns in the header record. /// </param> /// <param name="readOnly"> /// <see langword="true"/> if the header record is read-only, otherwise <see langword="false"/>. /// </param> public HeaderRecord(bool readOnly, IEnumerable<string> columnNames) : base(readOnly, columnNames) { columnNames.AssertNotNull("columnNames", true); this.columnNameToIndexMap = new Dictionary<string, int>(); this.PopulateColumnNameToIndexMap(0, true); if (readOnly) { this.columnNameToIndexMap = new ReadOnlyDictionary<string, int>(this.columnNameToIndexMap); } }
public ExercisePrograms(IEnumerable<ExerciseProgram> programs) { programs.AssertNotNull(nameof(programs), assertContentsNotNull: true); this.programs = programs.ToImmutableList(); }
public JsonSyntaxNode(IEnumerable<JsonSyntaxNode> children) { children.AssertNotNull(); this.children = new ReadOnlyCollection<JsonSyntaxNode>(children.ToList()); }