当前位置: 首页>>代码示例>>C#>>正文


C# Stack.ForEach方法代码示例

本文整理汇总了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;
        }
开发者ID:medvekoma,项目名称:portfotolio,代码行数:27,代码来源:UnityDecoratorBuildStrategy.cs

示例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;
开发者ID:xeno-by,项目名称:elf4b,代码行数:67,代码来源:VaultCompiler.cs


注:本文中的Stack.ForEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。