本文整理汇总了C#中ReadOnlyCollection.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollection.OfType方法的具体用法?C# ReadOnlyCollection.OfType怎么用?C# ReadOnlyCollection.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyCollection
的用法示例。
在下文中一共展示了ReadOnlyCollection.OfType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GCodeFile
private GCodeFile(List<Command> toolpath)
{
Toolpath = new ReadOnlyCollection<Command>(toolpath);
Vector3 min = Vector3.MaxValue, max = Vector3.MinValue;
foreach (Motion m in Enumerable.Concat(Toolpath.OfType<Line>(), Toolpath.OfType<Arc>().SelectMany(a => a.Split(0.1))))
{
for (int i = 0; i < 3; i++)
{
if (m.End[i] > max[i])
max[i] = m.End[i];
if (m.End[i] < min[i])
min[i] = m.End[i];
}
TravelDistance += m.Length;
}
Max = max;
Min = min;
Vector3 size = Max - Min;
for (int i = 0; i < 3; i++)
{
if (size[i] < 0)
size[i] = 0;
}
Size = size;
}
示例2: FormatCommenter
/// <inheritdoc cref="FormatCommenter(ITextBuffer, CommentFormat[])"/>
public FormatCommenter(ITextBuffer textBuffer, IEnumerable<CommentFormat> commentFormats)
{
Contract.Requires<ArgumentNullException>(textBuffer != null, "textBuffer");
Contract.Requires<ArgumentNullException>(commentFormats != null, "commentFormats");
Contract.Requires<ArgumentException>(!commentFormats.Contains(null));
this._textBuffer = textBuffer;
this._commentFormats = commentFormats.ToList().AsReadOnly();
this._blockFormats = _commentFormats.OfType<BlockCommentFormat>().ToList().AsReadOnly();
this._lineFormats = _commentFormats.OfType<LineCommentFormat>().ToList().AsReadOnly();
this._useLineComments = this._lineFormats.Count > 0;
}
示例3: Commenter
public Commenter(ITextView textView, ITextUndoHistoryRegistry textUndoHistoryRegistry, IEnumerable<CommentFormat> commentFormats)
{
Contract.Requires<ArgumentNullException>(textView != null, "textView");
Contract.Requires<ArgumentNullException>(textUndoHistoryRegistry != null, "textUndoHistoryRegistry");
Contract.Requires<ArgumentNullException>(commentFormats != null, "commentFormats");
this._textView = textView;
this._textUndoHistoryRegistry = textUndoHistoryRegistry;
this._commentFormats = commentFormats.ToList().AsReadOnly();
this._blockFormats = _commentFormats.OfType<BlockCommentFormat>().ToList().AsReadOnly();
this._lineFormats = _commentFormats.OfType<LineCommentFormat>().ToList().AsReadOnly();
this._useLineComments = this._lineFormats.Count > 0;
}
示例4: RecycleConfiguration
/// <summary>
/// Check service configuration update for changes that we cannot handle without a recycle.
/// </summary>
/// <param name="changes">Collection of changes from RoleEnvironmentChanging event.</param>
/// <returns>True if a non-handled configuration change was made, requiring a role recycle.</returns>
private bool RecycleConfiguration(ReadOnlyCollection<RoleEnvironmentChange> changes)
{
Func<RoleEnvironmentConfigurationSettingChange, bool> changeForcesRecycle =
x => !nonRecycleConfigurationItems.Contains(x.ConfigurationSettingName);
return changes.OfType<RoleEnvironmentConfigurationSettingChange>().Any(changeForcesRecycle);
}
示例5: GameVM
public GameVM(IGameBoardVM gameBoardVM, IEnumerable<IToolVM> tools)
{
GameBoard = gameBoardVM;
Tools = new ReadOnlyCollection<IToolVM>(tools.ToList());
foreach (var toolVM in Tools.OfType<ISelectableToolVM>())
{
toolVM.IsSelected += ToolIsSelected;
}
}
示例6: HasNonExemptConfigurationChanges
/// <summary>
/// HasNonExemptConfigurationChanges - Check if config changes contain any that aren't on our "exempt from recycle" list
/// Returns TRUE if there is at least one config change that isn't on our list.
/// </summary>
/// <param name="chgs">Collection of changes from RoleEnvironmentChanging or RoleEnvironmentChanged</param>
/// <returns></returns>
private bool HasNonExemptConfigurationChanges(ReadOnlyCollection<RoleEnvironmentChange> chgs)
{
Func<RoleEnvironmentConfigurationSettingChange, bool> changeIsNonExempt =
x => !ExemptConfigurations.Contains(x.ConfigurationSettingName);
var environmentChanges = chgs.OfType<RoleEnvironmentConfigurationSettingChange>();
return environmentChanges.Any(changeIsNonExempt);
}
示例7: AddMergeRedirectionExpressions
private void AddMergeRedirectionExpressions(
ReadOnlyCollection<RedirectionAst> redirections,
List<ParameterExpression> temps,
List<Expression> exprs,
List<Expression> finallyExprs)
{
foreach (var mergingRedirectionAst in redirections.OfType<MergingRedirectionAst>())
{
var savedPipes = NewTemp(typeof(Pipe[]), "savedPipes");
temps.Add(savedPipes);
var redirectionExpr = Expression.Constant(VisitMergingRedirection(mergingRedirectionAst));
exprs.Add(
Expression.Assign(savedPipes,
Expression.Call(redirectionExpr,
CachedReflectionInfo.MergingRedirection_BindForExpression,
_executionContextParameter,
_functionContext)));
// Undo merging redirections first (so file redirections get undone after).
finallyExprs.Insert(0, Expression.Call(redirectionExpr.Cast(typeof(CommandRedirection)),
CachedReflectionInfo.CommandRedirection_UnbindForExpression,
_functionContext,
savedPipes));
}
}
示例8: AddMergeRedirectionExpressions
private void AddMergeRedirectionExpressions(ReadOnlyCollection<RedirectionAst> redirections, List<ParameterExpression> temps, List<Expression> exprs, List<Expression> finallyExprs)
{
foreach (MergingRedirectionAst ast in redirections.OfType<MergingRedirectionAst>())
{
ParameterExpression item = this.NewTemp(typeof(Pipe[]), "savedPipes");
temps.Add(item);
ConstantExpression instance = Expression.Constant(this.VisitMergingRedirection(ast));
exprs.Add(Expression.Assign(item, Expression.Call(instance, CachedReflectionInfo.MergingRedirection_BindForExpression, _executionContextParameter, _functionContext)));
finallyExprs.Insert(0, Expression.Call(instance.Cast(typeof(CommandRedirection)), CachedReflectionInfo.CommandRedirection_UnbindForExpression, _functionContext, item));
}
}