本文整理汇总了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;
}
示例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;
}
示例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",
};
}
}
示例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());
}
示例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);
}