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


C# ReadOnlyCollectionBuilder.ToArray方法代码示例

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


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

示例1: GetConvertedArgs

            private static Expression[] GetConvertedArgs(params Expression[] args) {
                ReadOnlyCollectionBuilder<Expression> paramArgs = new ReadOnlyCollectionBuilder<Expression>(args.Length);

                for (int i = 0; i < args.Length; i++) {
                    paramArgs.Add(Expression.Convert(args[i], typeof(object)));
                }

                return paramArgs.ToArray();
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:9,代码来源:DynamicObject.cs

示例2: Reduce

        public override MSAst.Expression Reduce() {
            if (_names == _star) {
                // from a[.b] import *
                return GlobalParent.AddDebugInfo(
                    Ast.Call(
                        AstMethods.ImportStar,
                        Parent.LocalContext,
                        AstUtils.Constant(_root.MakeString()),
                        AstUtils.Constant(GetLevel())
                    ),
                    Span
                );
            } else {
                // from a[.b] import x [as xx], [ y [ as yy] ] [ , ... ]

                ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>();
                MSAst.ParameterExpression module = Ast.Variable(typeof(object), "module");

                // Create initializer of the array of names being passed to ImportWithNames
                MSAst.Expression[] names = new MSAst.Expression[_names.Length];
                for (int i = 0; i < names.Length; i++) {
                    names[i] = AstUtils.Constant(_names[i]);
                }

                // module = PythonOps.ImportWithNames(<context>, _root, make_array(_names))
                statements.Add(
                    GlobalParent.AddDebugInfoAndVoid(
                        AssignValue(
                            module,
                            LightExceptions.CheckAndThrow(
                                Expression.Call(
                                    AstMethods.ImportWithNames,
                                    Parent.LocalContext,
                                    AstUtils.Constant(_root.MakeString()),
                                    Ast.NewArrayInit(typeof(string), names),
                                    AstUtils.Constant(GetLevel())
                                )
                            )
                        ),
                        _root.Span
                    )
                );

                // now load all the names being imported and assign the variables
                for (int i = 0; i < names.Length; i++) {
                    statements.Add(
                        GlobalParent.AddDebugInfoAndVoid(
                            AssignValue(
                                Parent.GetVariableExpression(_variables[i]),
                                Ast.Call(
                                    AstMethods.ImportFrom,
                                    Parent.LocalContext,
                                    module,
                                    names[i]
                                )
                            ),
                            Span
                        )
                    );
                }

                statements.Add(AstUtils.Empty());
                return GlobalParent.AddDebugInfo(Ast.Block(new[] { module }, statements.ToArray()), Span);
            }
        }
开发者ID:jschementi,项目名称:iron,代码行数:65,代码来源:FromImportStatement.cs

示例3: GetConvertedArgs

            private static Expression[] GetConvertedArgs(params Expression[] args)
            {
                var paramArgs = new ReadOnlyCollectionBuilder<Expression>(args.Length);

                foreach (var t in args)
                {
                    paramArgs.Add(Expression.Convert(t, typeof(object)));
                }

                return paramArgs.ToArray();
            }
开发者ID:schmuli,项目名称:AspNetClientSessions,代码行数:11,代码来源:DynamicObject.cs

示例4: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {            
            if (_names == _star) {
                // from a[.b] import *
                return ag.AddDebugInfo(
                    Ast.Call(
                        AstGenerator.GetHelperMethod("ImportStar"),
                        ag.LocalContext, 
                        AstUtils.Constant(_root.MakeString()), 
                        AstUtils.Constant(GetLevel())
                    ),
                    Span
                );
            } else {
                // from a[.b] import x [as xx], [ y [ as yy] ] [ , ... ]

                ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>();
                MSAst.ParameterExpression module = ag.GetTemporary("module");

                // Create initializer of the array of names being passed to ImportWithNames
                MSAst.Expression[] names = new MSAst.Expression[_names.Length];
                for (int i = 0; i < names.Length; i++) {
                    names[i] = AstUtils.Constant(_names[i]);
                }

                // module = PythonOps.ImportWithNames(<context>, _root, make_array(_names))
                statements.Add(
                    ag.AddDebugInfoAndVoid(
                        GlobalAllocator.Assign(
                            module, 
                            Ast.Call(
                                AstGenerator.GetHelperMethod("ImportWithNames"),
                                ag.LocalContext,
                                AstUtils.Constant(_root.MakeString()),
                                Ast.NewArrayInit(typeof(string), names),
                                AstUtils.Constant(GetLevel())
                            )
                        ),
                        _root.Span
                    )
                );

                // now load all the names being imported and assign the variables
                for (int i = 0; i < names.Length; i++) {
                    statements.Add(
                        ag.AddDebugInfoAndVoid(
                            GlobalAllocator.Assign(
                                ag.Globals.GetVariable(ag, _variables[i]), 
                                Ast.Call(
                                    AstGenerator.GetHelperMethod("ImportFrom"),
                                    ag.LocalContext,
                                    module,
                                    names[i]
                                )
                            ),
                            Span
                        )
                    );
                }

                statements.Add(AstUtils.Empty());
                return ag.AddDebugInfo(Ast.Block(statements.ToArray()), Span);
            }
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:63,代码来源:FromImportStatement.cs

示例5: MakeClosureTuple

        internal Expression MakeClosureTuple()
        {
            if (_closureVariables == null)
                return Utils.Constant(null, typeof(MutableTuple));

            Debug.Assert(_closureVariables.Count > 0);
            Debug.Assert(_closureType != null);

            ReadOnlyCollectionBuilder<Expression> initializers = new ReadOnlyCollectionBuilder<Expression>();
            for (var i = 0; i < _closureVariables.Count; i++)
            {
                var closureExpression = Parent._variableMapping[_closureVariables[i]] as ClosureExpression;
                initializers.Add(closureExpression.ClosureCell);
            }

            var ret = MutableTuple.Create(
                initializers.ToArray()
            );
            Debug.Assert(ret.Type == _closureType);
            return ret;
        }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:21,代码来源:CompilableStmt.cs


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