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


C# System.Collections.Contains方法代码示例

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


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

示例1: ToList

        private static IList<object> ToList(object obj)
        {
            var list = new List<object>();

            if (obj == null)
            {
                return list;
            }

            var types = new[]
                            {
                                typeof(string), typeof(ObjectId),
                                typeof(Commit), typeof(TagAnnotation),
                                typeof(Tag), typeof(Branch), typeof(DetachedHead),
                                typeof(Reference), typeof(DirectReference), typeof(SymbolicReference)
                            };

            if (types.Contains(obj.GetType()))
            {
                list.Add(obj);
                return list;
            }

            list.AddRange(((IEnumerable)obj).Cast<object>());
            return list;
        }
开发者ID:Ran-QUAN,项目名称:libgit2sharp,代码行数:26,代码来源:CommitFilter.cs

示例2: RequiresSort

        public static bool RequiresSort(this IDomObject node)
        {
            var name = node.NodeName;

            if (string.IsNullOrWhiteSpace(name))
                return false;

            var sortable = new[] { "ITEMGROUP" };
            var result = sortable.Contains(name);
            return result;
        }
开发者ID:robcthegeek,项目名称:CsProjSorter,代码行数:11,代码来源:CsQueryExtensions.cs

示例3: Download

        public ActionResult Download()
        {
            var codeDict = _codeService.Query().ToDictionary(x => x.Id.ToString(), x => x.Label);

            using (var excel = new ExcelPackage())
            {
                var worksheet = excel.Workbook.Worksheets.Add("Agencies");
                worksheet.Cells[1, 1].Value = "Agencies";

                var exclude = new[] {"Codes", "UserId", "User", "IsNew"};
                var props = typeof(Agency).GetProperties()
                                          .Where(x => !exclude.Contains(x.Name))
                                          .ToList();

                //Header
                var row = worksheet.Dimension.End.Row + 1;
                for (var i = 0; i < props.Count; i++)
                {
                    worksheet.Cells[row, i + 1].Value = props[i].Name;
                }

                //Rows
                foreach (var agency in _agencyService.Query().Include(x => x.Codes).ToList())
                {
                    row = worksheet.Dimension.End.Row + 1;
                    for (var i = 0; i < props.Count; i++)
                    {
                        worksheet.Cells[row, i + 1].Value = GetValue(props[i], agency, codeDict);
                    }
                }

                return new FileContentResult(excel.GetAsByteArray(), MediaTypeNames.Application.Octet)
                {
                    FileDownloadName = "Agencies.xlsx",
                };
            }
        }
开发者ID:duggiemitchell,项目名称:Mentor,代码行数:37,代码来源:ExportAgencies.cs

示例4: LocalEnumerable_Contains

        public void LocalEnumerable_Contains()
        {
            var names = new[] {"Jack", "Bob"};
            var people = Collection.AsQueryable().Where(x => names.Contains(x.FirstName));

            var queryObject = ((IMongoQueryable)people).GetQueryObject();
            Assert.AreEqual(0, queryObject.Fields.ElementCount);
            Assert.AreEqual(0, queryObject.NumberToLimit);
            Assert.AreEqual(0, queryObject.NumberToSkip);
            Assert.AreEqual(@"{ ""fn"" : { ""$in"" : [""Jack"", ""Bob""] } }", queryObject.Query.ToJson());
        }
开发者ID:quentinproust,项目名称:fluent-mongo,代码行数:11,代码来源:MongoQueryProviderTests.cs

示例5: IsMethodSuitByName

		private static bool IsMethodSuitByName(string methodName, MemberInfo m)
		{
			var aliases = new[] { m.Name }.Concat(m.GetCustomAttributes<DynamicExpressionAliasAttribute>().Select(x => x.Name));

			return aliases.Contains(methodName, StringComparer.InvariantCultureIgnoreCase);
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:6,代码来源:ExpressionParser.cs


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