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


C# Seq.Select方法代码示例

本文整理汇总了C#中Seq.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Seq.Select方法的具体用法?C# Seq.Select怎么用?C# Seq.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Seq的用法示例。


在下文中一共展示了Seq.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NormalMethod

        private JST.FunctionExpression NormalMethod(CST.CSTWriter trace)
        {
            var cstmethod = CST.CSTMethod.Translate(methEnv, nameSupply, trace);
            var methCompEnv = MethodCompilerEnvironment.EnterMethod
                (env, outerNameSupply, nameSupply, rootId, assemblyId, typeDefinitionId, cstmethod.CompEnv, parent.TypeTrace);

            var simpCtxt = new CST.SimplifierContext(methCompEnv, nameSupply, this, trace);
            cstmethod = cstmethod.Simplify(simpCtxt);

            if (trace != null)
                trace.Trace("After simplification of intermediate representation", w2 => cstmethod.Append(w2));

            var usage = cstmethod.Body.Usage(methCompEnv);

            // Bind all type and value parameters
            var parameters = new Seq<JST.Identifier>();
            var body = new Seq<JST.Statement>();

            foreach (var id in methCompEnv.TypeBoundTypeParameterIds)
                parameters.Add(id);
            foreach (var id in methCompEnv.MethodBoundTypeParameterIds)
                parameters.Add(id);

            var delta = env.InteropManager.IsFactory(methCompEnv.Assembly, methCompEnv.Type, methCompEnv.Method) ? 1 : 0;
            for (var i = delta; i < methCompEnv.Method.Arity; i++)
            {
                var id = methCompEnv.ValueParameterIds[i];
                if (i == 0 && !methCompEnv.Method.IsStatic && methCompEnv.Type.Arity == 0)
                {
                    // Only instance methods of first-kinded types use 'this' for their first argument
                    if (usage.Variables.ContainsKey(id))
                        body.Add(JST.Statement.Var(id, new JST.ThisExpression()));
                }
                else
                    parameters.Add(id);
            }

            // Introduce the top level bindings based on usage
            methCompEnv.BindUsage(body, usage);

            // Introduce shared assembly/type/pointer bindings based on usage
            if (env.DebugMode)
                body.Add(new JST.CommentStatement("Locals"));
            var uninit = new Seq<JST.Identifier>();
            foreach (var kv in usage.Variables)
            {
                var v = methCompEnv.Variable(kv.Key);
                if (v.ArgLocal == CST.ArgLocal.Local)
                {
                    if (methCompEnv.Method.IsInitLocals && v.IsInit)
                        body.Add
                            (JST.Statement.Var(v.Id, env.JSTHelpers.DefaultExpressionForType(methCompEnv, v.Type)));
                    else
                        uninit.Add(v.Id);
                }
            }
            if (uninit.Count > 0)
                body.Add(new JST.VariableStatement(uninit.Select(id => new JST.VariableDeclaration(id)).ToSeq()));

            // Translate body to JavaScript statements/expressions
            foreach (var s in cstmethod.Body.Body)
                TranslateStatement(methCompEnv, body, s);

            var func = new JST.FunctionExpression(methCompEnv.MethodId, parameters, new JST.Statements(body));

            if (trace != null)
                trace.Trace
                    ("After translation to JavaScript",
                     w =>
                         {
                             func.Append(w);
                             w.EndLine();
                         });

            return func;
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:76,代码来源:MethodCompiler.cs


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