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


C# ReadOnlyCollection.ToList方法代码示例

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


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

示例1: MethodSignature

 public MethodSignature(string original, IEnumerable<TypeParameter> typeParameters, TypeReference returnType,
                        IEnumerable<TypeReference> parameters, IEnumerable<TypeReference> throws)
     : base(returnType, parameters)
 {
     this.original = original;
     typeParameters = typeParameters ?? Enumerable.Empty<TypeParameter>();
     this.typeParameters = typeParameters.ToList().AsReadOnly();
     throws = throws ?? Enumerable.Empty<TypeReference>();
     this.throws = throws.ToList().AsReadOnly();
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:MethodSignature.cs

示例2: Main

        private static void Main(string[] args)
        {
            IReadOnlyList<int> readonlyC = new ReadOnlyCollection<int>(new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            var writable = readonlyC.ToList();
            writable[0] = 11;
            readonlyC = writable;

            ((IList<int>)readonlyC)[0] = 12;
            Console.ReadLine();
        }
开发者ID:Elders,项目名称:Experiments,代码行数:11,代码来源:Program.cs

示例3: 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);
//.........这里部分代码省略.........
开发者ID:xeno-by,项目名称:truesight-lite,代码行数:101,代码来源:InitialDecompilation.cs


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