本文整理汇总了C#中ReadOnlyCollection.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollection.ForEach方法的具体用法?C# ReadOnlyCollection.ForEach怎么用?C# ReadOnlyCollection.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyCollection
的用法示例。
在下文中一共展示了ReadOnlyCollection.ForEach方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OrgItem
protected OrgItem(string name, IEnumerable<OrgItem> children)
{
Util.RequireNotNullOrEmpty(name, "name");
if (children == null) {
children = Enumerable.Empty<OrgItem>();
}
Name = name;
m_children = new ReadOnlyCollection<OrgItem>(children.ToArray());
m_children.ForEach(child => child.SetParent(this));
m_isVisible = true;
}
示例2: OrgItem
protected OrgItem(string name, IEnumerable<OrgItem> children)
{
Contract.Requires<ArgumentException>(!string.IsNullOrWhiteSpace(name));
if (children == null)
{
children = Enumerable.Empty<OrgItem>();
}
Name = name;
m_children = new ReadOnlyCollection<OrgItem>(children.ToArray());
m_children.ForEach(child => child.SetParent(this));
m_isVisible = true;
}
示例3: VisitExpressionList
/// <summary>
/// Visits a Expression List
/// </summary>
/// <param name="list">Expression List</param>
protected virtual void VisitExpressionList(ReadOnlyCollection<Expression> list)
{
list.ForEach<Expression>(e => Visit(e));
}
示例4: VisitElementInitializerList
/// <summary>
/// Visits a ElementInitializer List
/// </summary>
/// <param name="list">ElementInit List</param>
protected virtual void VisitElementInitializerList(ReadOnlyCollection<ElementInit> list)
{
list.ForEach<ElementInit>(e => VisitElementInitializer(e));
}
示例5: VisitBindingList
/// <summary>
/// Visits a BindingList
/// </summary>
/// <param name="list">MemberBinding List</param>
protected virtual void VisitBindingList(ReadOnlyCollection<MemberBinding> list)
{
list.ForEach<MemberBinding>(e => VisitBinding(e));
}
示例6: VisitParameterList
protected virtual ReadOnlyCollection<ParameterExpression> VisitParameterList(ReadOnlyCollection<ParameterExpression> list)
{
List<ParameterExpression> result = new List<ParameterExpression>();
list.ForEach<ParameterExpression>(e => result.Add(VisitParameter(e)));
return result.AsReadOnly();
}
示例7: VisitExpressionList
protected virtual ReadOnlyCollection<Expression> VisitExpressionList(ReadOnlyCollection<Expression> list)
{
List<Expression> result = new List<Expression>();
list.ForEach<Expression>(e => result.Add(Visit(e)));
return result.AsReadOnly();
}
示例8: VisitElementInitializerList
protected virtual ReadOnlyCollection<ElementInit> VisitElementInitializerList(ReadOnlyCollection<ElementInit> list)
{
List<ElementInit> result = new List<ElementInit>();
list.ForEach<ElementInit>(e => result.Add(VisitElementInitializer(e)));
return result.AsReadOnly();
}
示例9: VisitBindingList
protected virtual ReadOnlyCollection<MemberBinding> VisitBindingList(ReadOnlyCollection<MemberBinding> list)
{
List<MemberBinding> result = new List<MemberBinding>();
list.ForEach<MemberBinding>(e => result.Add(VisitBinding(e)));
return result.AsReadOnly();
}
示例10: FixupEvaluationOrder
private ReadOnlyCollection<Node> FixupEvaluationOrder(ReadOnlyCollection<Node> seq)
{
var q_evalOrders = new Dictionary<Node, ReadOnlyCollection<IILOp>>();
seq.ForEach(q => q_evalOrders[q] = q.CSharpEvaluationOrder().Where(n => n != null)
.Select(n => _map.GetOrDefault(n)).Where(op => op != null).ToReadOnly());
var evalOrder = q_evalOrders.SelectMany(kvp => kvp.Value).ToReadOnly();
var violatedDeps = new Dictionary<IILOp, ReadOnlyCollection<IILOp>>();
evalOrder.ForEach((op, i_op) => violatedDeps.Add(op, evalOrder.Where(
(oop, i_oop) => i_op > i_oop && op.Offset < oop.Offset).ToReadOnly()));
violatedDeps.RemoveElements(kvp => kvp.Value.IsEmpty());
if (violatedDeps.IsEmpty())
{
return seq;
}
else
{
var fixt = seq.ToList();
foreach (var op in violatedDeps.Keys)
{
if (op is Call)
{
var call = op.AssertCast<Call>();
if (call.Method.IsGetter()) /* implemented */ {}
else if (call.Method.IsSetter()) throw AssertionHelper.Fail();
else throw AssertionHelper.Fail();
}
else if (op is New) /* presume that ctors are stateless */ {}
else if (op is Ldloc) /* implemented */ {}
else if (op is Ldarg) /* implemented */ {}
else if (op is Ldelem) throw AssertionHelper.Fail();
else if (op is Ldfld) /* implemented */ {}
else if (op is Ldloca) /* implemented */ {}
else if (op is Ldarga) /* implemented */ {}
else if (op is Ldelema) throw AssertionHelper.Fail();
else if (op is Ldflda) /* implemented */ {}
else if (op is Ldind) throw AssertionHelper.Fail();
else if (op is Ldftn) throw AssertionHelper.Fail();
else if (op is Stloc) throw AssertionHelper.Fail();
else if (op is Starg) throw AssertionHelper.Fail();
else if (op is Stelem) throw AssertionHelper.Fail();
else if (op is Stfld) throw AssertionHelper.Fail();
else if (op is Stind) throw AssertionHelper.Fail();
// ops that neither read nor write from anywhere except stack
// can be freely skipped so we have to consider only a dozen of ops
else continue;
if (op is Ldloc || op is Ldloca)
{
var ldloc = op as Ldloc;
var ldloca = op as Ldloca;
var loc_il = ldloc != null ? ldloc.Loc :
ldloca != null ? ldloca.Loc : ((Func<ILocalVar>)(() => { throw AssertionHelper.Fail(); }))();
var violations = violatedDeps[op];
if (violations.OfType<Stloc>().Any(stloc => stloc.Index == loc_il.Index))
{
var loc_sym = _symbols.ResolveLocal(loc_il.Index);
var expr_ldloc = _mapOp(op).AssertCast<Ref>();
(expr_ldloc.Sym == loc_sym).AssertTrue();
var locName = loc_il.Source.DebugInfo == null ? ("loc" + loc_il.Index) :
!loc_il.Source.DebugInfo.LocalNames.ContainsKey(loc_il.Index) ? ("loc" + loc_il.Index) :
loc_il.Source.DebugInfo.LocalNames[loc_il.Index];
var bufLocName = Seq.Nats.Select(i => locName + "__CF$" + i.ToString("0000")).First(name1 => _symbols.Locals.None(loc1 => loc1.Name == name1));
var bufLoc = _symbols.IntroduceLocal(bufLocName, loc_il.Type);
var startOfViolations = q_evalOrders.Keys.First(q => Set.Intersect(q_evalOrders[q], violations).IsNotEmpty());
q_evalOrders[startOfViolations].Except(violations).AssertEmpty();
var insertionPoint = fixt.IndexOf(startOfViolations);
fixt.Insert(insertionPoint, new Assign(new Ref(bufLoc), new Ref(loc_sym)));
expr_ldloc.Parent.Children.ReplaceElements(expr_ldloc, new Ref(bufLoc));
}
}
if (op is Ldarg || op is Ldarga)
{
var ldarg = op as Ldarg;
var ldarga = op as Ldarga;
var arg_il = ldarg != null ? ldarg.Arg :
ldarga != null ? ldarga.Arg : ((Func<ParameterInfo>)(() => { throw AssertionHelper.Fail(); }))();
var arg_index = ldarg != null ? ldarg.Index :
ldarga != null ? ldarga.Index : ((Func<int>)(() => { throw AssertionHelper.Fail(); }))();
var violations = violatedDeps[op];
if (violations.OfType<Starg>().Any(starg => starg.Index == arg_index))
{
var arg_sym = _symbols.ResolveParam(arg_index);
var expr_ldarg = _mapOp(op).AssertCast<Ref>();
(expr_ldarg.Sym == arg_sym).AssertTrue();
var argName = arg_sym.Name;
var bufLocName = Seq.Nats.Select(i => argName + "__CF$" + i.ToString("0000")).First(name1 => _symbols.Locals.None(loc => loc.Name == name1));
var bufLoc = _symbols.IntroduceLocal(bufLocName, null);
var startOfViolations = q_evalOrders.Keys.First(q => Set.Intersect(q_evalOrders[q], violations).IsNotEmpty());
q_evalOrders[startOfViolations].Except(violations).AssertEmpty();
var insertionPoint = fixt.IndexOf(startOfViolations);
//.........这里部分代码省略.........