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


C# ReadOnlyCollection.First方法代码示例

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


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

示例1: IsDynamicComponentDictionaryGetter

		public static bool IsDynamicComponentDictionaryGetter(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, ISessionFactory sessionFactory, out string memberName)
		{
			memberName = null;

			// A dynamic component must be an IDictionary with a string key.

			if (method.Name != "get_Item" || !typeof(IDictionary).IsAssignableFrom(targetObject.Type))
				return false;

			var key = arguments.First().As<ConstantExpression>();
			if (key == null || key.Type != typeof(string))
				return false;

			// The potential member name
			memberName = (string)key.Value;

			// Need the owning member (the dictionary).
			var member = targetObject.As<MemberExpression>();
			if (member == null)
				return false;

			var metaData = sessionFactory.GetClassMetadata(member.Expression.Type);
			if (metaData == null)
				return false;

			// IDictionary can be mapped as collection or component - is it mapped as a component?
			var propertyType = metaData.GetPropertyType(member.Member.Name);
			return (propertyType != null && propertyType.IsComponentType);
		}
开发者ID:rancomarcus,项目名称:nhibernate-core,代码行数:29,代码来源:VisitorUtil.cs

示例2: OggStream

 protected OggStream(IEnumerable<Page> pages, IEnumerable<Packet> packets)
 {
     if (packets == null) throw new ArgumentNullException ("packets");
     Pages = new ReadOnlyCollection<Page>(pages.ToList());
     Packets = new ReadOnlyCollection<Packet> (packets.ToList ());
     
     SerialNumber = Pages.First().StreamSerialNumber;
 }
开发者ID:paszczi,项目名称:MLabs.Ogg,代码行数:8,代码来源:OggStream.cs

示例3: RegisteredQualifier

 public RegisteredQualifier(RegisteredCommand command, IEnumerable<string> names, string help)
     : base(command, help)
 {
     _names = new ReadOnlyCollection<string>(names.ToArray());
     var firstLongName = _names.FirstOrDefault(n => n.Length > 1);
     var firstName = _names.First();
     _name = firstLongName ?? firstName;
 }
开发者ID:enkafan,项目名称:commandline-parser,代码行数:8,代码来源:RegisteredQualifier.cs

示例4: LiteralConversion

		/// <summary> Creates a new literal conversion. </summary>
		/// <param name="components"> The components that can be successfully parsed. </param>
		/// <param name="result"> The result domain of the conversion. </param>
		public LiteralConversion(Domain result, ReadOnlyCollection<Domain> components)
		{
			Contract.Requires(components != null);
			Contract.Requires(components.Any(domain => domain.ToKind().IsLiteral()), "At least one literal must be present");
			Contract.Requires(Contract.ForAll(components, domain => Enum.IsDefined(typeof(Domain), domain)), "Undefined domain kind");
			Contract.Requires(Contract.ForAll(components, domain => domain.ToKind().IsOperand() || domain.ToKind().IsLiteral()), "No operators are allowed in the literal conversion");
			Contract.Requires(Enum.IsDefined(typeof(Domain), result));

			this.Components = components;
			this.Key = components.First(domain => domain.ToKind().IsLiteral());
			this.Result = result;
		}
开发者ID:JeroenBos,项目名称:ASDE,代码行数:15,代码来源:LiteralConversion.cs

示例5: KeyBindingData

        public KeyBindingData(ReadOnlyCollection<CommandKeyBinding> bindings)
        {
            // All bindings passed have the same KeyInput as their first key, so get it
            var firstKeyInput = bindings.First().KeyBinding.FirstKeyStroke;
            KeyName = KeyBinding.CreateKeyBindingStringForSingleKeyStroke(firstKeyInput);

            _bindings = bindings;
            _handledByOptions.AddRange(
                new[] {
                     _visualStudioOption = new KeyBindingHandledByOption("Visual Studio", bindings.Select(binding => binding.Name)),
                     _vsVimOption = new KeyBindingHandledByOption("VsVim", Enumerable.Empty<string>())
                });
        }
开发者ID:niklasi,项目名称:VsVim,代码行数:13,代码来源:KeyBindingData.cs

示例6: BuildHql

		public override HqlTreeNode BuildHql(
			MethodInfo method,
			Expression targetObject,
			ReadOnlyCollection<Expression> arguments,
			HqlTreeBuilder treeBuilder,
			IHqlExpressionVisitor visitor)
		{
			var left = treeBuilder.Cast(visitor.Visit(targetObject).AsExpression(), typeof(string));
			var right = treeBuilder.Cast(visitor.Visit(arguments.First()).AsExpression(), typeof(string));

			var leftSubstring = treeBuilder.MethodCall("substring", left, treeBuilder.Constant(4));
			var rightSubstring = treeBuilder.MethodCall("substring", right, treeBuilder.Constant(4));
			var equals = treeBuilder.Equality(leftSubstring, rightSubstring);
			return equals;
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:15,代码来源:EntityWithUserTypePropertyIsEquivalentGenerator.cs

示例7: KeyBindingData

        public KeyBindingData(ReadOnlyCollection<CommandKeyBinding> bindings)
        {
            // All bindings passed have the same KeyInput as their first key, so get it
            var firstKeyInput = bindings.First().KeyBinding.FirstKeyStroke;
            KeyName = KeyBinding.CreateKeyBindingStringForSingleKeyStroke(firstKeyInput);

            // It's possible that Visual Studio will bind multiple key strokes to the same
            // command.  Often it will be things like "Ctrl-[, P" and "Ctr-[, Ctrl-P".  In
            // that case we don't want to list the command twice so filter that possibility
            // out here
            var commandNames = bindings.Select(x => x.Name).Distinct(StringComparer.OrdinalIgnoreCase);

            _bindings = bindings;
            _handledByOptions.AddRange(
                new[] {
                     _visualStudioOption = new KeyBindingHandledByOption("Visual Studio", commandNames),
                     _vsVimOption = new KeyBindingHandledByOption("VsVim", Enumerable.Empty<string>())
                });
        }
开发者ID:honeyhoneywell,项目名称:VsVim,代码行数:19,代码来源:KeyBindingData.cs

示例8: Bind

        public override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel)
        {
            Console.WriteLine("cache miss");

            ParameterExpression firstParameterExpression = parameters.First();

            return Expression.IfThenElse(
                //if
                Expression.GreaterThanOrEqual(
                    firstParameterExpression,
                    Expression.Constant(5)),
                    //then
                    Expression.Return(
                        returnLabel,
                        Expression.Constant(10)),
                    //else
                    Expression.Return(
                        returnLabel,
                        Expression.Constant(1)));
        }
开发者ID:serakrin,项目名称:presentations,代码行数:20,代码来源:ConstantBinderWithRule.cs

示例9: EvaluateStatardMemberAccess

 protected object EvaluateStatardMemberAccess(string propertyName, ReadOnlyCollection<Expression> operands)
 {
     return operands[0].Type.GetProperty(propertyName).GetValue(operands.First().Evaluate(), null);
 }
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:4,代码来源:SpecialExpression.cs

示例10: BuildFieldProperty

 static JToken BuildFieldProperty(ReadOnlyCollection<string> fields)
 {
     return fields.Count == 1
         ? new JProperty("field", fields.First())
         : new JProperty("fields", new JArray(fields));
 }
开发者ID:CenturyLinkCloud,项目名称:ElasticLINQ,代码行数:6,代码来源:SearchRequestFormatter.cs

示例11: OnNavigatedTo

 public async override void OnNavigatedTo(object navigationParameter, NavigationMode navigationMode, Dictionary<string, object> viewState)
 {
     try
     {
         var productNumber = navigationParameter as string;
         var selectedProduct = await _productCatalogRepository.GetProductAsync(productNumber);
         var productViewModels = (await _productCatalogRepository.GetProductsAsync(selectedProduct.SubcategoryId))
                                                                 .Select(product => new ProductViewModel(product, _shoppingCartRepository));
         
         Items = new ReadOnlyCollection<ProductViewModel>(productViewModels.ToList());
         
         SelectedProduct = Items.First(p => p.ProductNumber == productNumber);
         Title = SelectedProduct.Title;
         IsSelectedProductPinned = _tileService.SecondaryTileExists(SelectedProduct.ProductNumber);
         _searchPaneService.ShowOnKeyboardInput(true);
     }
     catch (HttpRequestException)
     {
         var task = _alertService.ShowAsync(_resourceLoader.GetString("ErrorServiceUnreachable"), _resourceLoader.GetString("Error"));
     }
 }
开发者ID:stevenh77,项目名称:ItineraryHunter-Win8,代码行数:21,代码来源:ItemDetailPageViewModel.cs

示例12: PickPluginFromMultipleSupportedPlugins

        /// <summary>
        /// The pick plugin from multiple supported plugins.
        /// </summary>
        /// <param name="pluginsToUse">
        /// The plugins to use.
        /// </param>
        /// <returns>
        /// The <see cref="IPlugin"/>.
        /// </returns>
        public IPlugin PickPluginFromMultipleSupportedPlugins(ReadOnlyCollection<IPlugin> pluginsToUse)
        {
            if (pluginsToUse != null && pluginsToUse.Any())
            {
                return pluginsToUse.First();
            }

            return null;
        }
开发者ID:NMarouschek,项目名称:VSSonarQubeExtension,代码行数:18,代码来源:PluginController.cs

示例13: PopulateStatesAsync

        public async Task PopulateStatesAsync()
        {
            var items = new List<ComboBoxItemValue> { new ComboBoxItemValue() { Id = string.Empty, Value = _resourceLoader.GetString("State") } };
            var states = await _locationService.GetStatesAsync();

            items.AddRange(states.Select(state => new ComboBoxItemValue() { Id = state, Value = state }));
            States = new ReadOnlyCollection<ComboBoxItemValue>(items);

            // Select the first item on the list
            // But disable validation first, because we don't want to fire validation at this point
            _address.IsValidationEnabled = false;
            _address.State = States.First().Id;
            _address.IsValidationEnabled = true;
        }
开发者ID:stevenh77,项目名称:ItineraryHunter-Win8,代码行数:14,代码来源:BillingAddressUserControlViewModel.cs

示例14: VisitGroupBy

 private void VisitGroupBy(ReadOnlyCollection<Expression> selectGroupBy)
 {
     sb.Append("(");
     if (selectGroupBy != null)
     {
         if (selectGroupBy.Count ==1)
         {
             ColumnExpression colexpr = (ColumnExpression) selectGroupBy.First();
             sb.AppendFormat("(enlist `{0})!enlist `{0}", colexpr.Name);
         }
         else
         {
             throw new  NotImplementedException("");
         }
     }
     //&& selectGroupBy.Count > 0)
     //{
     //    for (int i = 0, n = selectGroupBy.Count; i < n; i++)
     //    {
     //        if (i > 0)
     //        {
     //            sb.Append(", ");
     //        }
     //        VisitValue(selectGroupBy[i]);
     //    }
     //}
     sb.Append(")");
 }
开发者ID:ScottWeinstein,项目名称:Linq2KdbQ,代码行数:28,代码来源:QFormatter.cs

示例15: PopulateStatesAsync

        public async Task PopulateStatesAsync()
        {
            string errorMessage = string.Empty;
            try
            {
                var states = await _locationService.GetStatesAsync();

                var items = new List<ComboBoxItemValue> { new ComboBoxItemValue() { Id = string.Empty, Value = _resourceLoader.GetString("State") } };
                items.AddRange(states.Select(state => new ComboBoxItemValue() { Id = state, Value = state }));
                States = new ReadOnlyCollection<ComboBoxItemValue>(items);

                // Select the first item on the list
                // But disable validation first, because we don't want to fire validation at this point
                _address.IsValidationEnabled = false;
                _address.State = States.First().Id;
                _address.IsValidationEnabled = true;
            }
            catch (Exception ex)
            {
                errorMessage = string.Format(CultureInfo.CurrentCulture, _resourceLoader.GetString("GeneralServiceErrorMessage"), Environment.NewLine, ex.Message);
            }

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                await _alertMessageService.ShowAsync(errorMessage, _resourceLoader.GetString("ErrorServiceUnreachable"));
            }
        }
开发者ID:CruzerBoon,项目名称:Prism-Samples-Windows,代码行数:27,代码来源:BillingAddressUserControlViewModel.cs


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