本文整理汇总了C#中IEnumerable.ToImmutableList方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.ToImmutableList方法的具体用法?C# IEnumerable.ToImmutableList怎么用?C# IEnumerable.ToImmutableList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.ToImmutableList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exercise
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);
}
}
示例2: PhotoSet
public PhotoSet(string id, PhotoSetType type, string displayName, IEnumerable<Photo> photos)
{
this.Id = id;
this.Type = type;
this.DisplayName = displayName;
this.Photos = photos.ToImmutableList();
}
示例3: XRefCollection
public XRefCollection(IEnumerable<Uri> uris)
{
if (uris == null)
{
throw new ArgumentNullException(nameof(uris));
}
Uris = uris.ToImmutableList();
}
示例4: FSharpCompilationFailure
public FSharpCompilationFailure(
string filePath,
IEnumerable<FSharpCompilationMessage> messages)
{
_filePath = filePath;
_fileContent = File.Exists(filePath) ? File.ReadAllText(filePath) : null;
_messages = messages.ToImmutableList();
}
示例5: ValuesEntity
public ValuesEntity(string id, DateTimeOffset createdOn, DateTimeOffset lastModifiedOn, DateTimeOffset lastAccessedOn, IEnumerable<string> values = null)
{
this.Id = id;
this.CreatedOn = createdOn;
this.LastModifiedOn = lastModifiedOn;
this.LastAccessedOn = lastAccessedOn;
this.Values = values == null ? ImmutableList<string>.Empty : values.ToImmutableList();
}
示例6: Configuration
public Configuration(
IEnumerable<Transformation> namespaceTransformations,
IEnumerable<Transformation> nameTransformations,
IEnumerable<Filter> interfaceFilters)
{
this.namespaceTransformations = namespaceTransformations.ToImmutableList();
this.nameTransformations = nameTransformations.ToImmutableList();
this.interfaceFilters = interfaceFilters.ToImmutableList();
}
示例7: SearchMethodInfo
public SearchMethodInfo(SearchTypeInfo type, string methodName, IEnumerable<string> parameters = null,
IEnumerable<string> typeParameters = null, bool? isStatic = null, bool? isAbstract = null)
{
Type = type;
MethodName = methodName;
Parameters = parameters?.ToImmutableList();
TypeParameters = typeParameters == null ? ImmutableList<string>.Empty : (typeParameters.ToImmutableList());
IsStatic = isStatic;
IsAbstract = isAbstract;
}
示例8: MetronomeAction
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));
}
示例9: ParallelAction
public ParallelAction(IEnumerable<IAction> children)
{
Ensure.ArgumentNotNull(children, nameof(children), assertContentsNotNull: true);
this.children = children.ToImmutableList();
this.duration = this
.children
.Select(x => x.Duration)
.DefaultIfEmpty()
.Max();
}
示例10: SequenceAction
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);
}
示例11: TextChangeEventArgs
/// <summary>
/// Initializes an instance of <see cref="TextChangeEventArgs"/>.
/// </summary>
/// <param name="oldText">The text before the change.</param>
/// <param name="newText">The text after the change.</param>
/// <param name="changes">A non-empty set of ranges for the change.</param>
public TextChangeEventArgs(SourceText oldText, SourceText newText, IEnumerable<TextChangeRange> changes)
{
if (changes == null || changes.IsEmpty())
{
throw new ArgumentException("changes");
}
this.OldText = oldText;
this.NewText = newText;
this.Changes = changes.ToImmutableList();
}
示例12: ClassificationResult
public ClassificationResult(
IEnumerable<SuspiciousNode> suspiciousNodes, IEnumerable<BigInteger> wronglyAcceptedFeatures,
IEnumerable<BigInteger> wronglyRejectedFeatures, int wrongVectorCount, int wrongElementCount,
EncodingResult encodingResult) {
SuspiciousNodes = suspiciousNodes != null ? suspiciousNodes.ToImmutableList() : null;
WronglyAcceptedVectors = wronglyAcceptedFeatures.ToImmutableList();
WronglyRejectedVectors = wronglyRejectedFeatures.ToImmutableList();
WrongVectorCount = wrongVectorCount;
WrongElementCount = wrongElementCount;
_vector2Node = encodingResult.Vector2Node;
}
示例13: ExerciseProgram
public ExerciseProgram(ILoggerService loggerService, string name, IEnumerable<Exercise> exercises)
{
Ensure.ArgumentNotNull(loggerService, nameof(loggerService));
Ensure.ArgumentNotNull(name, nameof(name));
Ensure.ArgumentNotNull(exercises, 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);
}
示例14: RuleReference
public RuleReference(Implication originalRule, IEnumerable<PropNetFlattener.Condition> conditions, IList<Term> productionTemplate = null)
{
OriginalRule = originalRule;
ProductionTemplate = productionTemplate==null ? ImmutableList<Term>.Empty : productionTemplate.ToImmutableList();
Conditions = conditions.ToImmutableList();
int producttionTemplateHashCode = 1;
if (productionTemplate != null)
foreach (Term term in productionTemplate)
producttionTemplateHashCode = 31 * producttionTemplateHashCode + (term == null ? 0 : term.GetHashCode());
int conditionsHashcode = Conditions.Aggregate(1, (current, cond) => 31 * current + (cond == null ? 0 : cond.GetHashCode()));
_hashCode = producttionTemplateHashCode + conditionsHashcode;
}
示例15: Step
private Step(Step step, IEnumerable<Cell> cells, IEnumerable<Cell> rotateCells, Cell newCenter)
{
height = step.height;
width = step.width;
pieceIndex = step.pieceIndex;
commandIndex = step.commandIndex + 1;
points = step.points;
Center = newCenter;
Pieces = step.Pieces;
CurrentPieceCells = rotateCells.ToImmutableList();
UsedCells = step.UsedCells;
RunningCells = cells.ToImmutableHashSet();
}