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


C# IList.OfType方法代码示例

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


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

示例1: FindMatchingItems

        // This behavior is case sensitive
        public override IEnumerable<object> FindMatchingItems(string searchText, IList items, IEnumerable<object> escapedItems, string textSearchPath, TextSearchMode textSearchMode)
        {
            var strings = searchText.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (strings.Length == 0)
            {
                return base.FindMatchingItems(searchText, items, escapedItems, textSearchPath, textSearchMode);
            }

            string name = string.Empty;
            string capital = string.Empty;
            if (strings.Length > 0)
            {
                name = strings[0];
            }

            if (strings.Length > 1)
            {
                capital = strings[1].TrimStart(' ');
            }

            IEnumerable<object> results = null;
            if (textSearchMode == TextSearchMode.Contains)
            {
                results = items.OfType<Country>().Where(x => x.Name.Contains(name) && x.Capital.Contains(capital));
            }
            else
            {
                results = items.OfType<Country>().Where(x => x.Name.StartsWith(name) && x.Capital.StartsWith(capital));
            }

            return results.Where(x => !escapedItems.Contains(x));
        }
开发者ID:jigjosh,项目名称:xaml-sdk,代码行数:33,代码来源:MyFilteringBehavior.cs

示例2: ShouldHumanize

        private static bool ShouldHumanize(ModelMetadata modelMetadata, IList<Attribute> propertyAttributes)
        {
            if (string.IsNullOrEmpty(modelMetadata.PropertyName))
                return false;

            if (propertyAttributes.OfType<DisplayNameAttribute>().Any())
                return false;

            if (propertyAttributes.OfType<DisplayAttribute>().Any())
                return false;

            return true;
        }
开发者ID:InnovateEDUNYC,项目名称:NGLV1,代码行数:13,代码来源:CustomMetadataProvider.cs

示例3: IsTransformRequired

        private static bool IsTransformRequired(ModelMetadata modelMetadata, IList<Attribute> propertyAttributes)
        {
            if (string.IsNullOrEmpty(modelMetadata.PropertyName))
                return false;

            if (propertyAttributes.OfType<DisplayNameAttribute>().Any())
                return false;

            if (propertyAttributes.OfType<DisplayAttribute>().Any())
                return false;

            return true;
        }
开发者ID:Jamleck,项目名称:Humanizer,代码行数:13,代码来源:HumanizerMetadataProvider.cs

示例4: CopyRequestHeaders

        /// <summary>
        /// Copies HTTP Request Headers from parent request to all requests from multi-part child requests.
        /// This fixes a problem where content negotiation does not work correctly and JSON is always returned
        /// even when the client expects xml+atom.
        /// </summary>
        public virtual void CopyRequestHeaders(HttpRequestMessage request, IList<ODataBatchRequestItem> items)
        {
            var requests =
                items.OfType<OperationRequestItem>().Select(o => o.Request)
                    .Union(items.OfType<ChangeSetRequestItem>().SelectMany(cs => cs.Requests));

            foreach (var childRequest in requests)
            {
                foreach (var header in request.Headers)
                {
                    childRequest.Headers.Add(header.Key, request.Headers.GetValues(header.Key));
                }
            }
        }
开发者ID:Pliner,项目名称:TinyFeed,代码行数:19,代码来源:HeaderCascadingODataBatchHandler.cs

示例5: ListPickerBox

		protected ListPickerBox(IList items, IList selectedItems, bool singleSelection, string _title, bool minOneSelected = true, bool showSelectAllButton = false)
		{
			InitializeComponent();
			this.minOneSelected = minOneSelected; 

			if (string.IsNullOrEmpty(_title))
				title.Visibility = Visibility.Collapsed;
			else
				title.Text = _title; 

			if (selectedItems == null)
				selectedItems = new List<object>();

			SelectAllButton.Visibility = showSelectAllButton ? Visibility.Visible : Visibility.Collapsed;

			list.ItemTemplate = (DataTemplate)(singleSelection ? Resources["singleTemplate"] : Resources["multipleTemplate"]);
			OriginalSelectedItems = selectedItems; 
			
			Dispatcher.BeginInvoke(delegate
			{
				Items = items.OfType<object>().
					Select(i => new ListPickerBoxItem { Item = i, IsChecked = selectedItems.Contains(i) }).
					ToList();

				UpdateSelectedItems();
				UpdateSelectAllButton();

				list.ItemsSource = Items; 
			});
		}
开发者ID:RareNCool,项目名称:MyToolkit,代码行数:30,代码来源:ListPickerBox.xaml.cs

示例6: GetDependentVariables

        /// <summary>
        /// Creates a dictionary describing argument based dependencies for the given list of functions.
        /// </summary>
        /// <param name="functions"></param>
        /// <returns></returns>
        public static IDictionary<IVariable, IEnumerable<IVariable>> GetDependentVariables(IList<IFunction> functions)
        {
            var result = new Dictionary<IVariable, IEnumerable<IVariable>>();

            var variables = functions.OfType<IVariable>();

            foreach (var variable in variables)
            {
                var variable1 = variable;
                result[variable] = functions.OfType<IVariable>()
                    .Where(variable2 => variable2.Arguments.Contains(variable1))
                    .ToList();
            }

            return result;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:21,代码来源:MemoryFunctionStoreHelper.cs

示例7: ClassDefinition

		public ClassDefinition(Token classToken, Token nameToken, Token baseClassToken, IList<Executable> members)
			: base(classToken)
		{
			this.NameToken = nameToken;
			this.BaseClassToken = baseClassToken;
			this.Members = members.OfType<FunctionDefinition>().ToArray();
		}
开发者ID:blakeohare,项目名称:crython,代码行数:7,代码来源:ClassDefinition.cs

示例8: StartSearchAsync

        public async Task<IEnumerable<IMediaFile>> StartSearchAsync(IList filesOrDirsCollection)
        {
            this.IsWorking = true;
            // create the cancellation token source
            this.CancelToken = new CancellationTokenSource();
            // create the cancellation token
            var token = this.CancelToken.Token;

            this.MainTask = Task<IEnumerable<IMediaFile>>.Factory
              .StartNew(() => {
                  var results = new ConcurrentQueue<IMediaFile>();

                  // get audio files from input collection
                  var rawFiles = filesOrDirsCollection.OfType<string>().Where(this.IsAudioFile).OrderBy(s => s).ToList();
                  foreach (var rawFile in rawFiles.TakeWhile(rawDir => !token.IsCancellationRequested))
                  {
                      var mf = this.GetMediaFile(rawFile);
                      if (mf != null)
                      {
                          results.Enqueue(mf);
                      }
                  }

                  // handle all directories from input collection
                  var directories = new List<string>();
                  foreach (var source in filesOrDirsCollection.OfType<string>().Except(rawFiles).Where(IsDirectory).TakeWhile(source => !token.IsCancellationRequested))
                  {
                      directories.AddRange(GetSubFolders(token, source));
                  }

                  var orderedDirs = directories.Distinct().OrderBy(s => s);
                  this.Log().Debug("search for files in {0} directories (sub directories included)", orderedDirs.Count());

                  foreach (var rawDir in orderedDirs.TakeWhile(rawDir => !token.IsCancellationRequested))
                  {
                      this.DoFindFiles(token, rawDir, results);
                  }

                  return results;
              }, token, TaskCreationOptions.LongRunning, TaskScheduler.Current);

            var mediaFiles = await this.MainTask;

            this.IsWorking = false;

            return mediaFiles;
        }
开发者ID:kaushik1605,项目名称:sample_DotNet,代码行数:47,代码来源:FileSearchWorker.cs

示例9: Render

        protected override void Render(IList<IBaseTexture> inputs)
        {
            var texture = inputs.OfType<ITexture2D>().SingleOrDefault();
            if (texture == null)
                return;

            Render(texture);
        }
开发者ID:mysteryx93,项目名称:MPDN_Extensions,代码行数:8,代码来源:Filter.Utilities.cs

示例10: CompiledFilter

 public CompiledFilter(MIA_Management miaManagement, IFilter filter, Namespace ns, BindVarNamespace bvNamespace, string outerMIIDJoinVariable, ICollection<TableJoin> tableJoins)
 {
   _statementParts = new List<object>();
   _statementBindVars = new List<BindVar>();
   _requiredMIATypes = new List<MediaItemAspectMetadata>();
   CompileStatementParts(miaManagement, filter, ns, bvNamespace, _requiredMIATypes, outerMIIDJoinVariable, tableJoins,
       _statementParts, _statementBindVars);
   _requiredAttributes = _statementParts.OfType<QueryAttribute>().ToList();
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:9,代码来源:CompiledFilter.cs

示例11: CopyRequestHeadersToBatchItems

        /// <summary>
        /// OData does not copy headers from the main request to the batch sub-request. Let's do it here...
        /// </summary>
        public virtual void CopyRequestHeadersToBatchItems(HttpRequestMessage request, IList<ODataBatchRequestItem> items)
        {
            var batchRequests = items
                .OfType<OperationRequestItem>().Select(o => o.Request)
                .Union(items.OfType<ChangeSetRequestItem>().SelectMany(cs => cs.Requests));

            foreach (var batchRequest in batchRequests)
            {
                foreach (var header in request.Headers)
                {
                    if (String.Equals(header.Key, DataServiceVersionHeader, StringComparison.OrdinalIgnoreCase) ||
                        String.Equals(header.Key, MaxDataServiceVersionHeader, StringComparison.OrdinalIgnoreCase))
                    {
                        batchRequest.Headers.Add(header.Key, request.Headers.GetValues(header.Key));
                    }
                }
            }
        }
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:21,代码来源:ODataServiceVersionHeaderPropagatingBatchHandler.cs

示例12: GetDevice

 protected static Device GetDevice(IList<ICallCopyEntity> callCopyEntities)
 {
     Device device = callCopyEntities.OfType<Device>().FirstOrDefault();
     if (device == null)
     {
         device = new Device {Name = "Placeholder", DeviceType = "Placeholder"};
         callCopyEntities.Add(device);
     }
     return device;
 }
开发者ID:PillarTechnology,项目名称:Revaction,代码行数:10,代码来源:AbstractTranslationService.cs

示例13: StartSearchAsync

    public async Task<IEnumerable<IMediaFile>> StartSearchAsync(IList filesOrDirsCollection) {
      this.IsWorking = true;
      // create the cancellation token source
      this.cancelToken = new CancellationTokenSource();
      // create the cancellation token
      var token = this.cancelToken.Token;

      this.mainTask = Task<IEnumerable<IMediaFile>>.Factory
        .StartNew(() => {
          var results = new ConcurrentQueue<IMediaFile>();

          // get audio files from input collection
          var rawFiles = filesOrDirsCollection.OfType<string>().Where(this.IsAudioFile).OrderBy(s => s).ToList();
          foreach (var rawFile in rawFiles.TakeWhile(rawDir => !token.IsCancellationRequested)) {
            var mf = this.GetMediaFile(rawFile);
            if (mf != null) {
              results.Enqueue(mf);
            }
          }

          // handle all directories from input collection
          var directories = new List<string>();
          foreach (var source in filesOrDirsCollection.OfType<string>().Except(rawFiles).Where(IsDirectory).TakeWhile(source => !token.IsCancellationRequested)) {
            directories.Add(source);
            try {
              directories.AddRange(Directory.EnumerateDirectories(source, "*", SearchOption.AllDirectories).TakeWhile(dir => !token.IsCancellationRequested));
            } catch (Exception e) {
              // System.UnauthorizedAccessException
              Console.WriteLine(e);
            }
          }
          foreach (var rawDir in directories.Distinct().OrderBy(s => s).TakeWhile(rawDir => !token.IsCancellationRequested)) {
            this.doFindFiles(token, rawDir, results);
          }

          return results;
        }, token, TaskCreationOptions.LongRunning, TaskScheduler.Current);

      var mediaFiles = await this.mainTask;
      this.IsWorking = false;
      return mediaFiles;
    }
开发者ID:phaufe,项目名称:simple-music-player,代码行数:42,代码来源:FileSearchWorker.cs

示例14: IndexerNode

        public IndexerNode(IList<object> arguments)
        {
            Arguments = arguments;

            var intArgs = Arguments.OfType<int>().ToArray();

            if (intArgs.Length == arguments.Count)
            {
                _intArgs = intArgs;
            }
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:11,代码来源:IndexerNode.cs

示例15: SelectClauseHandler

 public SelectClauseHandler(SelectClause clause)
 {
     _references = clause.Columns.ToList();
     _resolvers = _references.Select(ValueResolver.Create).ToList();
     if (_resolvers.OfType<AggregateValueResolver>().Any())
     {
         _groupingHandler =
             new GroupingHandler(
                 _references.Where(ReferenceIsNotAggregateFunction).Select(r => r.GetAliasOrName()).ToArray());
     }
 }
开发者ID:ChrisMH,项目名称:Simple.Data,代码行数:11,代码来源:SelectClauseHandler.cs


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