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


C# IEnumerable.ToReadOnly方法代码示例

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


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

示例1: CSharpSetMemberBinder

		public CSharpSetMemberBinder (CSharpBinderFlags flags, string name, Type callingContext, IEnumerable<CSharpArgumentInfo> argumentInfo)
			: base (name, false)
		{
			this.flags = flags;
			this.callingContext = callingContext;
			this.argumentInfo = argumentInfo.ToReadOnly ();
		}
开发者ID:jdecuyper,项目名称:mono,代码行数:7,代码来源:CSharpSetMemberBinder.cs

示例2: CSharpInvokeBinder

		public CSharpInvokeBinder (CSharpBinderFlags flags, Type callingContext, IEnumerable<CSharpArgumentInfo> argumentInfo)
			: base (CSharpArgumentInfo.CreateCallInfo (argumentInfo, 1))
		{
			this.flags = flags;
			this.callingContext = callingContext;
			this.argumentInfo = argumentInfo.ToReadOnly ();
		}
开发者ID:robterrell,项目名称:playscript-mono,代码行数:7,代码来源:CSharpInvokeBinder.cs

示例3: ClientJoinExpression

 public ClientJoinExpression(ProjectionExpression projection, IEnumerable<Expression> outerKey, IEnumerable<Expression> innerKey)
     : base(DbExpressionType.ClientJoin, projection.Type)
 {
     this.outerKey = outerKey.ToReadOnly();
     this.innerKey = innerKey.ToReadOnly();
     this.projection = projection;
 }
开发者ID:PaybackMan,项目名称:Cinder,代码行数:7,代码来源:ClientJoinExpression.cs

示例4: UpdateCommandExpression

 public UpdateCommandExpression(IdentifiableExpression identifiable, Expression where, IEnumerable<FieldAssignment> assignments)
     : base(DbExpressionType.Update, typeof(int))
 {
     this.identifiable = identifiable;
     this.where = where;
     this.assignments = assignments.ToReadOnly();
 }
开发者ID:PaybackMan,项目名称:Cinder,代码行数:7,代码来源:UpdateCommandExpression.cs

示例5: LoadProvinces

 public void LoadProvinces(IEnumerable<Province> provinces)
 {
     Provinces = provinces.ToReadOnly();
     SeaProvinces = Provinces.OfType<SeaProvince>().ToReadOnly();
     LandProvinces = Provinces.OfType<LandProvince>().ToReadOnly();
     ProvincePicker.Initialize(Provinces.First().Zones.First());
 }
开发者ID:ndech,项目名称:Alpha,代码行数:7,代码来源:ProvinceManager.cs

示例6: Switch

        public static SwitchExpression Switch(Expression value, LabelTarget label, IEnumerable<SwitchCase> cases) {
            RequiresCanRead(value, "value");
            ContractUtils.Requires(value.Type == typeof(int), "value", Strings.ValueMustBeInt);
            ContractUtils.RequiresNotNull(cases, "cases");
            var caseList = cases.ToReadOnly();
            ContractUtils.RequiresNotEmpty(caseList, "cases");
            ContractUtils.RequiresNotNullItems(caseList, "cases");
            // TODO: does it make sense for switch to have non-void type?
            ContractUtils.Requires(label == null || label.Type == typeof(void), "label", Strings.LabelTypeMustBeVoid);

            bool @default = false;
            int max = Int32.MinValue;
            int min = Int32.MaxValue;
            foreach (SwitchCase sc in caseList) {
                if (sc.IsDefault) {
                    ContractUtils.Requires(@default == false, "cases", Strings.OnlyDefaultIsAllowed);
                    @default = true;
                } else {
                    int val = sc.Value;
                    if (val > max) max = val;
                    if (val < min) min = val;
                }
            }

            ContractUtils.Requires(UniqueCaseValues(caseList, min, max), "cases", Strings.CaseValuesMustBeUnique);

            return new SwitchExpression(value, label, caseList);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:28,代码来源:SwitchExpression.cs

示例7: VariableDictionary

 public static Expression VariableDictionary(IEnumerable<ParameterExpression> variables) {
     var vars = variables.ToReadOnly();
     return Expression.New(
         typeof(LocalsDictionary).GetConstructor(new[] { typeof(IRuntimeVariables), typeof(SymbolId[]) }),
         Expression.RuntimeVariables(vars),
         AstUtils.Constant(vars.Map(v => SymbolTable.StringToIdOrEmpty(v.Name)))
     );
 }
开发者ID:apboyle,项目名称:ironruby,代码行数:8,代码来源:VariableDictionaryExpression.cs

示例8: CSharpInvokeMemberBinder

		public CSharpInvokeMemberBinder (CSharpBinderFlags flags, string name, Type callingContext, IEnumerable<Type> typeArguments, IEnumerable<CSharpArgumentInfo> argumentInfo)
			: base (name, false, CSharpArgumentInfo.CreateCallInfo (argumentInfo, 1))
		{
			this.flags = flags;
			this.callingContext = callingContext;
			this.argumentInfo = argumentInfo.ToReadOnly ();
			this.typeArguments = typeArguments.ToReadOnly ();
		}
开发者ID:afaerber,项目名称:mono,代码行数:8,代码来源:CSharpInvokeMemberBinder.cs

示例9: ListBind

 //CONFORMING
 ///<summary>Creates a <see cref="T:System.Linq.Expressions.MemberListBinding" /> where the member is a field or property.</summary>
 ///<returns>A <see cref="T:System.Linq.Expressions.MemberListBinding" /> that has the <see cref="P:System.Linq.Expressions.MemberBinding.BindingType" /> property equal to <see cref="F:System.Linq.Expressions.MemberBindingType.ListBinding" /> and the <see cref="P:System.Linq.Expressions.MemberBinding.Member" /> and <see cref="P:System.Linq.Expressions.MemberListBinding.Initializers" /> properties set to the specified values.</returns>
 ///<param name="member">A <see cref="T:System.Reflection.MemberInfo" /> that represents a field or property to set the <see cref="P:System.Linq.Expressions.MemberBinding.Member" /> property equal to.</param>
 ///<param name="initializers">An <see cref="T:System.Collections.Generic.IEnumerable`1" /> that contains <see cref="T:System.Linq.Expressions.ElementInit" /> objects to use to populate the <see cref="P:System.Linq.Expressions.MemberListBinding.Initializers" /> collection.</param>
 ///<exception cref="T:System.ArgumentNullException">
 ///<paramref name="member" /> is null. -or-One or more elements of <paramref name="initializers" /> is null.</exception>
 ///<exception cref="T:System.ArgumentException">
 ///<paramref name="member" /> does not represent a field or property.-or-The <see cref="P:System.Reflection.FieldInfo.FieldType" /> or <see cref="P:System.Reflection.PropertyInfo.PropertyType" /> of the field or property that <paramref name="member" /> represents does not implement <see cref="T:System.Collections.IEnumerable" />.</exception>
 public static MemberListBinding ListBind(MemberInfo member, IEnumerable<ElementInit> initializers) {
     ContractUtils.RequiresNotNull(member, "member");
     ContractUtils.RequiresNotNull(initializers, "initializers");
     Type memberType;
     ValidateGettableFieldOrPropertyMember(member, out memberType);
     ReadOnlyCollection<ElementInit> initList = initializers.ToReadOnly();
     ValidateListInitArgs(memberType, initList);
     return new MemberListBinding(member, initList);
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:18,代码来源:MemberListBinding.cs

示例10: ElementInit

 //CONFORMING
 public static ElementInit ElementInit(MethodInfo addMethod, IEnumerable<Expression> arguments) {
     ContractUtils.RequiresNotNull(addMethod, "addMethod");
     ContractUtils.RequiresNotNull(arguments, "arguments");
     RequiresCanRead(arguments, "arguments");
     ValidateElementInitAddMethodInfo(addMethod);
     ReadOnlyCollection<Expression> argumentsRO = arguments.ToReadOnly();
     ValidateArgumentTypes(addMethod, ExpressionType.Call, ref argumentsRO);
     return new ElementInit(addMethod, argumentsRO);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:10,代码来源:ElementInit.cs

示例11: Dynamic

        /// <summary>
        /// Creates a <see cref="DynamicExpression" /> that represents a dynamic operation bound by the provided <see cref="CallSiteBinder" />.
        /// </summary>
        /// <param name="binder">The runtime binder for the dynamic operation.</param>
        /// <param name="returnType">The result type of the dynamic expression.</param>
        /// <param name="arguments">The arguments to the dynamic operation.</param>
        /// <returns>
        /// A <see cref="DynamicExpression" /> that has <see cref="NodeType" /> equal to
        /// <see cref="ExpressionType.Dynamic">Dynamic</see> and has the
        /// <see cref="DynamicExpression.Binder">Binder</see> and
        /// <see cref="DynamicExpression.Arguments">Arguments</see> set to the specified values.
        /// </returns>
        /// <remarks>
        /// The <see cref="DynamicExpression.DelegateType">DelegateType</see> property of the
        /// result will be inferred from the types of the arguments and the specified return type.
        /// </remarks>
        public static DynamicExpression Dynamic(CallSiteBinder binder, Type returnType, IEnumerable<Expression> arguments)
        {
            ContractUtils.RequiresNotNull(arguments, nameof(arguments));
            ContractUtils.RequiresNotNull(returnType, nameof(returnType));

            var args = arguments.ToReadOnly();
            ContractUtils.RequiresNotEmpty(args, nameof(args));
            return MakeDynamic(binder, returnType, args);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:25,代码来源:Expression.netstandard1.7.cs

示例12: SwitchCase

        /// <summary>
        /// Creates a <see cref="System.Linq.Expressions.SwitchCase">SwitchCase</see> for use in a <see cref="SwitchExpression"/>.
        /// </summary>
        /// <param name="body">The body of the case.</param>
        /// <param name="testValues">The test values of the case.</param>
        /// <returns>The created <see cref="System.Linq.Expressions.SwitchCase">SwitchCase</see>.</returns>
        public static SwitchCase SwitchCase(Expression body, IEnumerable<Expression> testValues) {
            RequiresCanRead(body, "body");
            
            var values = testValues.ToReadOnly();
            RequiresCanRead(values, "testValues");
            ContractUtils.RequiresNotEmpty(values, "testValues");

            return new SwitchCase(body, values);
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:15,代码来源:SwitchCase.cs

示例13: MemberBind

 /// <summary>
 /// Creates a <see cref="MemberMemberBinding"/> that represents the recursive initialization of members of a field or property. 
 /// </summary>
 /// <param name="member">The <see cref="MemberInfo"/> to set the <see cref="P:MemberBinding.Member"/> property equal to.</param>
 /// <param name="bindings">An <see cref="IEnumerable{T}"/> that contains <see cref="MemberBinding"/> objects to use to populate the <see cref="P:MemberMemberBindings.Bindings"/> collection.</param>
 /// <returns>A <see cref="MemberMemberBinding"/> that has the <see cref="P:MemberBinding.BindingType"/> property equal to <see cref="MemberBinding"/> and the <see cref="P:MemberBinding.Member"/> and <see cref="P:MemberMemberBindings.Bindings"/> properties set to the specified values.</returns>
 public static MemberMemberBinding MemberBind(MemberInfo member, IEnumerable<MemberBinding> bindings) {
     ContractUtils.RequiresNotNull(member, "member");
     ContractUtils.RequiresNotNull(bindings, "bindings");
     ReadOnlyCollection<MemberBinding> roBindings = bindings.ToReadOnly();
     Type memberType;
     ValidateGettableFieldOrPropertyMember(member, out memberType);
     ValidateMemberInitArgs(memberType, roBindings);
     return new MemberMemberBinding(member, roBindings);
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:15,代码来源:MemberMemberBinding.cs

示例14: SwitchCase

        /// <summary>
        /// Creates a <see cref="Expressions.SwitchCase"/> for use in a <see cref="SwitchExpression"/>.
        /// </summary>
        /// <param name="body">The body of the case.</param>
        /// <param name="testValues">The test values of the case.</param>
        /// <returns>The created <see cref="Expressions.SwitchCase"/>.</returns>
        public static SwitchCase SwitchCase(Expression body, IEnumerable<Expression> testValues)
        {
            RequiresCanRead(body, nameof(body));

            ReadOnlyCollection<Expression> values = testValues.ToReadOnly();
            ContractUtils.RequiresNotEmpty(values, nameof(testValues));
            RequiresCanRead(values, nameof(testValues));

            return new SwitchCase(body, values);
        }
开发者ID:alessandromontividiu03,项目名称:corefx,代码行数:16,代码来源:SwitchCase.cs

示例15: ListInit

 //CONFORMING
 public static ListInitExpression ListInit(NewExpression newExpression, IEnumerable<Expression> initializers) {
     ContractUtils.RequiresNotNull(newExpression, "newExpression");
     ContractUtils.RequiresNotNull(initializers, "initializers");
     ReadOnlyCollection<Expression> initializerlist = initializers.ToReadOnly();
     if (initializerlist.Count == 0) {
         throw Error.ListInitializerWithZeroMembers();
     }
     MethodInfo addMethod = FindMethod(newExpression.Type, "Add", null, new Expression[] { initializerlist[0] }, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     return ListInit(newExpression, addMethod, initializers);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:11,代码来源:ListInitExpression.cs


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