本文整理汇总了C#中Stack.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# Stack.ForEach方法的具体用法?C# Stack.ForEach怎么用?C# Stack.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack.ForEach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreBuildUp
public override void PreBuildUp(IBuilderContext context)
{
NamedTypeBuildKey key = context.OriginalBuildKey;
if (!(key.Type.IsInterface && _typeStacks.ContainsKey(key.Type)))
{
return;
}
if (null != context.GetOverriddenResolver(key.Type))
{
return;
}
var stack = new Stack<Type>(_typeStacks[key.Type]);
object value = null;
stack.ForEach(type =>
{
value = context.NewBuildUp(new NamedTypeBuildKey(type, key.Name));
var overrides = new DependencyOverride(key.Type, value);
context.AddResolverOverrides(overrides);
}
);
context.Existing = value;
context.BuildComplete = true;
}
示例2: ImplementCreateProperties
//.........这里部分代码省略.........
Action<IBranch> updateCp = b =>
{
var get = propGetCache[b.VPath];
cp.il()
.ldarg(0)
.callvirt(typeof(CompiledNode).GetProperty("Properties").GetGetMethod())
.ldarg(0)
.ldstr(b.GetPropertyName())
.ldstr(b.VPath)
.newobj(typeof(VPath), typeof(String))
.ldarg(0)
.ldftn(get)
.newobj(typeof(Func<IEsathObject>), typeof(Object), typeof(IntPtr))
.newobj(typeof(CompiledProperty), typeof(CompiledNode), typeof(String), typeof(VPath), typeof(Func<IEsathObject>))
.callvirt(typeof(CompiledPropertyCollection).GetMethod("Add"));
};
// handle deleted flae and svds i.e. create CompiledNode.Eval-like crash
if (special)
{
foreach (IBranch deleted in relevantCumulations.Where(co => co.Reason == EventReason.Remove).Select(co => co.Subject))
{
ensureProperty(deleted, false);
var get = (MethodBuilder)propGetCache[deleted.VPath];
get.il()
.ldstr(String.Format("There's no compiled property at VPath '{0}'.", deleted.VPath))
[email protected](typeof(NotImplementedException), typeof(String));
updateCp(deleted);
}
}
// define all properties in advance so that we can reference them when needed
svdAndFormulae.ForEach(b => ensureProperty(b, false));
// implement defined properties
foreach (var b in svdAndFormulae)
{
var typeToken = b.GetValue("type").ContentString;
var propType = typeToken.GetTypeFromToken();
var f_prop = fieldCache[b.VPath];
var get = (MethodBuilder)propGetCache[b.VPath];
// if a formula has just been created (i.e. has null elfCode), then we just generate notimplemented stuff
// todo. this is a particular case of graceful dealing with invalid elf code
// a solid approach would also handle such stuff as: non-existing references, resolving to invalid methods
// and i think something else (needs thorough checking)
// note. when implementing that stuff, be sure to burn the failboat elf code + the failure reason right into the assembly code
// so that one can analyze the formula by him/herself and find the reason of the failure
if (b.IsFormula())
{
var host = b.GetValue("elfCode");
var code = host == null ? null : host.ContentString;
var elfCode = code == null ? null : code.ToCanonicalElf();
if (elfCode == null)
{
get.il()[email protected](typeof(NotImplementedException));
updateCp(b);
continue;
}
}
Label cacheOk;