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


C# IReadOnlyCollection.First方法代码示例

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


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

示例1: GenerateNext

		private static Func<IMessage, Task<object>> GenerateNext(
			BusSettings busSettings,
			IDependencyScope dependencyScope,
			IReadOnlyCollection<Type> pipelineHandlerTypes,
			IEnumerable<Type> leftHandlerTypes
			)
		{
			return (async message => {

				if (message == null) {
					throw new NullMessageTypeException();
				}

				if (!pipelineHandlerTypes.Any()) {
					return await RunLeafHandlers(busSettings, dependencyScope, leftHandlerTypes, message);
				}

				var head = pipelineHandlerTypes.First();
				var nextHandler = (IPipelineHandler)dependencyScope.GetService(head);

				var tail = pipelineHandlerTypes.Skip(1).ToList();
				var nextFunction = GenerateNext(busSettings, dependencyScope, tail, leftHandlerTypes);

				return await nextHandler.Handle(nextFunction, message);
			});
		}
开发者ID:Sandboxed-Forks,项目名称:Enexure.MicroBus,代码行数:26,代码来源:PipelineBuilder.cs

示例2: CombinedNodeCommandWrapper

 public CombinedNodeCommandWrapper(IViewModelServiceProvider serviceProvider, string name, IReadOnlyCollection<ModelNodeCommandWrapper> commands)
     : base(serviceProvider)
 {
     if (commands == null) throw new ArgumentNullException(nameof(commands));
     if (commands.Count == 0) throw new ArgumentException(@"The collection of commands to combine is empty", nameof(commands));
     if (commands.Any(x => !ReferenceEquals(x.NodeCommand, commands.First().NodeCommand))) throw new ArgumentException(@"The collection of commands to combine cannot contain different node commands", nameof(commands));
     this.commands = commands;
     Name = name;
 }
开发者ID:cg123,项目名称:xenko,代码行数:9,代码来源:CombinedNodeCommandWrapper.cs

示例3: CombinedNodeCommandWrapper

 public CombinedNodeCommandWrapper(IViewModelServiceProvider serviceProvider, string name, string observableNodePath, ObservableViewModelIdentifier identifier, IReadOnlyCollection<ModelNodeCommandWrapper> commands)
     : base(serviceProvider, null)
 {
     if (commands == null) throw new ArgumentNullException("commands");
     if (commands.Count == 0) throw new ArgumentException(@"The collection of commands to combine is empty", "commands");
     if (commands.Any(x => !ReferenceEquals(x.NodeCommand, commands.First().NodeCommand))) throw new ArgumentException(@"The collection of commands to combine cannot contain different node commands", "commands");
     service = serviceProvider.Get<ObservableViewModelService>();
     this.commands = commands;
     this.name = name;
     this.identifier = identifier;
     this.serviceProvider = serviceProvider;
     ObservableNodePath = observableNodePath;
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:13,代码来源:CombinedNodeCommandWrapper.cs

示例4: GetCommonRoot

        private static string GetCommonRoot(IReadOnlyCollection<string> normalizedPaths)
        {
            if (normalizedPaths.Count == 0)
                return string.Empty;

            var maxPathLength = normalizedPaths.Max(s => s.Length);
            var longestPath = normalizedPaths.First(p => p.Length == maxPathLength)
                .Split(Path.DirectorySeparatorChar)
                .Select(p => p + Path.DirectorySeparatorChar);

            var result = string.Empty;

            foreach (var path in longestPath)
            {
                // If this is the first path segment we need check whether it's a valid
                // prefix of all paths.
                //
                // If it's not then it means there is no common root.

                if (result.Length == 0 && normalizedPaths.All(p => p.StartsWith(path)))
                {
                    result = path;
                    continue;
                }

                // We already have a path.
                //
                // In that case the combined path must be a valid prefix.

                var fullPath = Path.Combine(result, path);
                if (normalizedPaths.All(p => p.StartsWith(fullPath)))
                {
                    result = fullPath;
                    continue;
                }

                break;
            }

            return result;
        }
开发者ID:NN---,项目名称:nuproj,代码行数:41,代码来源:AssignSourceTargetPaths.cs

示例5: AlbumPhoto

        private static AlbumPhoto AlbumPhoto(IReadOnlyCollection<Photo> photos, AlbumPhoto previous)
        {
            if (photos.Count == 0)
            {
                return null;
            }

            var head = photos.First();
            var tail = photos.Skip(1).ToList();

            var headPhoto = new AlbumPhoto
            {
                Photo = head,
                Previous = previous
            };

            var tailPhotos = AlbumPhoto(tail, headPhoto);

            headPhoto.Next = tailPhotos;

            return headPhoto;
        }
开发者ID:smgoodman84,项目名称:smgoodman.co.uk,代码行数:22,代码来源:PhotoAlbum.cs

示例6: AfterShapesAdded

		void AfterShapesAdded(IReadOnlyCollection<Shape> newShapes)
		{
			_selectedShapes.Clear();
			_selectedShapes.Add(_partialSelShape);
			if (newShapes.Count == 1) {
				var s = newShapes.First();
				_partialSelShape = s;
				_focusShape = s;
			}
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:10,代码来源:DiagramControl.cs

示例7: 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 it at this point
            _address.IsValidationEnabled = false;
            _address.State = States.First().Id;
            _address.IsValidationEnabled = true;
        }
开发者ID:stevenh77,项目名称:ItineraryHunter-Win8,代码行数:14,代码来源:ShippingAddressUserControlViewModel.cs

示例8: SmoothPath

 private List<Node> SmoothPath(IReadOnlyCollection<Node> path)
 {
     var currentNode = path.Last();
     var smoothPath = new List<Node> {currentNode};
     for (var i = path.Count - 2; i >= 0; i--)
     {
         if (!IsValidNode(path.ElementAt(i), currentNode))
         {
             smoothPath.Add(path.ElementAt(i + 1));
             currentNode = path.ElementAt(i + 1);
         }
     }
     smoothPath.Add(path.First());
     return smoothPath;
 }
开发者ID:HassanNiazi,项目名称:SSL_HUB,代码行数:15,代码来源:Rrt.cs

示例9: 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,代码行数:30,代码来源:ShippingAddressUserControlViewModel.cs

示例10: AggregateActionItems

 private static IActionItem AggregateActionItems(IReadOnlyCollection<IActionItem> actionItems, string name = null)
 {
     if (actionItems.Count == 1)
     {
         var actionItem = actionItems.First();
         if (!string.IsNullOrEmpty(name))
             actionItem.Name = name;
         return actionItem;
     }
     return new AggregateActionItem(name, actionItems.ToArray());
 }
开发者ID:FERRERDEV,项目名称:xenko,代码行数:11,代码来源:TransactionalActionStack.cs

示例11: RequestAdd

 public void RequestAdd (IReadOnlyCollection<Contracts.Options> options)
 {
   foreach (var vm in _optionsViewModelFactory.Create (options, _generalOptions))
     _options.Add (vm);
   if (options.Any())
     ShowProfile (options.First().Id);
 }
开发者ID:aluxnimm,项目名称:outlookcaldavsynchronizer,代码行数:7,代码来源:OptionsCollectionViewModel.cs

示例12: Combine

        public static Stream Combine(IReadOnlyCollection<MemoryStream> imageStreams)
        {
            if (imageStreams == null) throw new ArgumentNullException("imageStreams");
            if (!imageStreams.Any()) throw new ArgumentException("imageStream cannot be empty.");

            var images = imageStreams.Select(Image.FromStream);
            var outputStream = new MemoryStream();

            // Handle the case where only one image stream is provided.
            if (imageStreams.Count == 1)
            {
                imageStreams.First().CopyTo(outputStream);
            }
            else
            {
                using (var combinedImage = images.Aggregate((image1, image2) =>
                {
                    try
                    {
                        return image1.Combine(image2, 0);
                    }
                    finally
                    {
                        image1.Dispose();
                        image2.Dispose();
                    }
                }))
                {
                    combinedImage.Save(outputStream, ImageFormat.Png);
                }
            }

            return outputStream;
        }
开发者ID:eHanlin,项目名称:Hanlin.Common,代码行数:34,代码来源:ImageUtils.cs

示例13: GetDefaultLayout

        private static ILayoutInfo GetDefaultLayout(IReadOnlyCollection<ILayoutInfo> layoutList)
        {
            if (layoutList == null || layoutList.Count == 0)
                return null;

            var item =
                layoutList.FirstOrDefault(
                    l => (l.IsDefault ?? false) && (l.AccountId == Utils.CurrentUserAccountId || (l.AccountId == 0 && Utils.CurrentUserAccountId == -1)));
            if (item != null)
                return item;

            if (layoutList.Any(l => l.IsAdminDefault ?? false))
                return layoutList.First(l => l.IsAdminDefault ?? false);

            return layoutList.First();
        }
开发者ID:mparsin,项目名称:Elements,代码行数:16,代码来源:SearchUtils.cs

示例14: IsStraight

 private bool IsStraight(IReadOnlyCollection<int> list)
 {
     return list.Count == 5 && list.Distinct().Count() == 5 && list.First() == _start && list.Last() == _end;
 }
开发者ID:jjvdgeer,项目名称:Yahtzee,代码行数:4,代码来源:StraightCalculator.cs

示例15: CaptureHeaders

 private Dictionary<string, string[]> CaptureHeaders(IReadOnlyCollection<string> captureHeaders, IHeaderDictionary headers)
 {
     Dictionary<string, string[]> capturedHeaders = null;
     if (captureHeaders != null && captureHeaders.Any())
     {
         capturedHeaders = new Dictionary<string, string[]>();
         if (captureHeaders.First() == "*")
         {
             foreach (KeyValuePair<string, string[]> kvp in headers)
             {
                 string[] existingHeader;
                 if (capturedHeaders.TryGetValue(kvp.Key, out existingHeader))
                 {
                     existingHeader = existingHeader.Union(kvp.Value).ToArray();
                 }
                 else
                 {
                     existingHeader = kvp.Value;
                 }
                 capturedHeaders[kvp.Key] = existingHeader;
             }
         }
         else
         {
             foreach (string headerName in captureHeaders)
             {
                 string[] values;
                 if (headers.TryGetValue(headerName, out values))
                 {
                     capturedHeaders.Add(headerName, values);
                 }
             }
         }
     }
     return capturedHeaders;
 } 
开发者ID:gorkar,项目名称:AccidentalFish.ApplicationSupport.Owin,代码行数:36,代码来源:HttpLogger.cs


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