本文整理汇总了C#中Collection.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.Where方法的具体用法?C# Collection.Where怎么用?C# Collection.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection.Where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttributeFeed
public AttributeFeed(Collection<AttributeAssignment> assignments, string specialPrefix)
{
this.specialPrefix = specialPrefix;
prefixDefinitions = assignments.Where(IsNamespaceDefinition).Select(GetNsDefinition);
attributes = assignments.Where(IsAttribute);
directives = assignments.Where(IsDirective).Select(ExtractDirectives);
}
示例2: lock
void IWpfTextViewConnectionListener.SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
{
lock (s_gate)
{
// only add roslyn type to tracking map
foreach (var buffer in subjectBuffers.Where(b => b.ContentType.IsOfType(ContentTypeNames.RoslynContentType)))
{
HashSet<IWpfTextView> set;
if (!s_map.TryGetValue(buffer, out set))
{
set = new HashSet<IWpfTextView>();
s_map.Add(buffer, set);
}
set.Add(textView);
DebugRegisterView_NoLock(textView);
}
}
var handlers = this.SubjectBuffersConnected;
if (handlers != null)
{
handlers(this, new SubjectBuffersConnectedEventArgs(textView, subjectBuffers.ToReadOnlyCollection()));
}
}
示例3: RemoveAttributes
private void RemoveAttributes(Collection<CustomAttribute> customAttributes)
{
foreach (var customAttribute in customAttributes.Where(IsWeakEventAttribute).ToList())
{
customAttributes.Remove(customAttribute);
}
}
示例4: getFields
private Signature getFields(string parent, Collection<FieldDefinition> fields, string type)
{
var field = fields
.Where(x => type.Equals(string.Format("{0}.{1}", parent, x.Name)))
.FirstOrDefault();
if (field == null)
return null;
return new Signature(SignatureTypes.Field, field.FullName);
}
示例5: SubjectBuffersDisconnected
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
{
foreach (var buffer in subjectBuffers.Where(b => b.ContentType.IsOfType("css")))
{
CssTreeWatcher watcher;
if (buffer.Properties.TryGetProperty(typeof(CssTreeWatcher), out watcher))
watcher.Tree = null;
}
}
示例6: getMethods
private Signature getMethods(string parent, Collection<MethodDefinition> methods, string type)
{
var method = methods
.Where(x => type.Equals(string.Format("{0}.{1}", parent, x.Name)))
.FirstOrDefault();
if (method == null)
return null;
return new Signature(SignatureTypes.Method, method.FullName);
}
示例7: RemoveAttributes
void RemoveAttributes(Collection<CustomAttribute> customAttributes)
{
var attributes = customAttributes
.Where(attribute => _propertyAttributeNames.Contains(attribute.Constructor.DeclaringType.FullName));
foreach (var customAttribute in attributes.ToList())
{
customAttributes.Remove(customAttribute);
}
}
示例8: RemoveAttributes
void RemoveAttributes(Collection<CustomAttribute> customAttributes, string fullName)
{
var attributes = customAttributes
.Where(attribute => propertyAttributeNames.Contains(attribute.Constructor.DeclaringType.Name));
foreach (var customAttribute in attributes.ToList())
{
logger.LogMessage(string.Format("\tRemoving attribute '{0}' from '{1}'.", customAttribute.Constructor.DeclaringType.FullName, fullName));
customAttributes.Remove(customAttribute);
}
}
示例9: LMGetMetadata
static IEnumerable<ControllerDefinition> LMGetMetadata(Collection<ApiDescription> descriptions) {
var apiGroups = descriptions
.Where(a => !a.ActionDescriptor.ControllerDescriptor.ControllerType.IsAbstract
&& !a.RelativePath.Contains("Swagger")
&& !a.RelativePath.Contains("docs"))
.ToLookup(a => a.ActionDescriptor.ControllerDescriptor);
return apiGroups.Select(d => new ControllerDefinition {
Name = d.Key.ControllerName,
ActionMethods = descriptions.Where(a => !a.RelativePath.Contains("Swagger")
&& !a.RelativePath.Contains("docs")
&& a.ActionDescriptor.ControllerDescriptor.ControllerName == d.Key.ControllerName).
Select(a => new ActionMethodDefinition {
Name = a.ActionDescriptor.ActionName,
BodyParameter = a.ParameterDescriptions.
Where(b => b.Source == ApiParameterSource.FromBody).
Select(b => new ParameterDefinition {
Name = b.ParameterDescriptor.ParameterName,
Type = b.ParameterDescriptor.ParameterType,
}).
FirstOrDefault(),
UrlParameters = a.ParameterDescriptions.
Where(b => b.ParameterDescriptor != null && b.Source == ApiParameterSource.FromUri).
Select(b => new ParameterDefinition {
Name = b.ParameterDescriptor.ParameterName,
Type = b.ParameterDescriptor.ParameterType,
}),
Url = a.RelativePath,
ReturnType = a.ResponseDescription.ResponseType ?? a.ResponseDescription.DeclaredType,
HttpMethod = a.HttpMethod.Method
})
}).
Distinct().
OrderBy(d => d.Name);
}
示例10: Minus
/// <summary>
/// Разность множеств между всеми игроками и участниками покера (результат - те игроки, которые не являются участниками)
/// </summary>
/// <param name="participants"></param>
/// <returns></returns>
protected Collection<IPlayer> Minus(Collection<Participant> participants)
{
var players = (from x in MyDataContextBase.Players select x).ToList(); // все игроки
var list = new Collection<IPlayer>();
var indexDel = new Collection<Player>();
foreach (var t in players)
foreach (var par in participants.Where(par => t == par.ParticipantPlayer))
indexDel.Add(par.ParticipantPlayer);
foreach (var l in indexDel)
players.Remove(l);
foreach (var p in players) // добавляем всех остальных
list.Add(p);
return list;
}
示例11: lock
void IWpfTextViewConnectionListener.SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
{
lock (s_gate)
{
// only add roslyn type to tracking map
foreach (var buffer in subjectBuffers.Where(b => IsSupportedContentType(b.ContentType)))
{
if (!s_map.TryGetValue(buffer, out var set))
{
set = new HashSet<IWpfTextView>();
s_map.Add(buffer, set);
}
set.Add(textView);
DebugRegisterView_NoLock(textView);
}
}
this.SubjectBuffersConnected?.Invoke(this, new SubjectBuffersConnectedEventArgs(textView, subjectBuffers.ToReadOnlyCollection()));
}
示例12: CacheProperties
public static void CacheProperties(Collection<DataProperty> properties)
{
if (properties == null)
{
throw new ArgumentNullException("list");
}
var handle = IntPtr.Zero;
foreach (var item in properties.Where(item => !PropertiesCache.Contains(item)))
{
if (handle == IntPtr.Zero)
{
handle = OpenMsipackage();
}
var stringSize = 0;
if (MsiMethods.MsiGetProperty(handle, item.Id, new StringBuilder(0), ref stringSize)
!= (int)MsiMethods.ErrorCodes.MoreData)
{
continue;
}
stringSize += 1;
var sb = new StringBuilder(stringSize);
if (MsiMethods.MsiGetProperty(handle, item.Id, sb, ref stringSize)
== (int)MsiMethods.ErrorCodes.Success)
{
item.Value = sb.ToString();
PropertiesCache.Add(item);
}
}
if (handle != IntPtr.Zero)
{
MsiMethods.MsiCloseHandle(handle);
}
}
示例13: SiteNewsModel
public SiteNewsModel(String baseHttpUrl, String newsContentFilePath)
{
this.FeedItems = new List<SyndicationItem>();
var news = new Collection<NewsItem>();
var blogPosts = new Collection<BlogPost>();
String[] blogDataFiles = Directory.GetFiles(newsContentFilePath, "*.html");
foreach (var blogDataFile in blogDataFiles)
{
BlogPost blogPost = new BlogPost(baseHttpUrl, blogDataFile);
String postAnnounementTitle;
switch (blogPost.PrimaryZone)
{
case "News":
postAnnounementTitle = String.Format("<a href=\"{0}\">{1}</a>", blogPost.InternalHttpPath, blogPost.Title);
break;
case "Reviews":
postAnnounementTitle = String.Format("New review: <a href=\"{0}\">{1}</a>", blogPost.InternalHttpPath, blogPost.Title);
break;
case "Articles":
postAnnounementTitle = String.Format("New article: <a href=\"{0}\">{1}</a>", blogPost.InternalHttpPath, blogPost.Title);
break;
case "Projects":
postAnnounementTitle = String.Format("New project post: <a href=\"{0}\">{1}</a>", blogPost.InternalHttpPath, blogPost.Title);
break;
default:
postAnnounementTitle = String.Format("<a href=\"{0}\">{1}</a>", blogPost.InternalHttpPath, blogPost.Title);
break;
}
String blogHtml;
if (blogPost.PreviewAvailable)
{
StringBuilder blogHtmlBuilder = new StringBuilder();
blogHtmlBuilder.Append(blogPost.PostPreviewHtml);
blogHtmlBuilder.AppendFormat("...<br/><br/><a href=\"{0}\">Read more</a><br/>", blogPost.InternalHttpPath);
blogHtml = blogHtmlBuilder.ToString();
}
else
{
blogHtml = blogPost.PostHtml;
}
blogPosts.Add(blogPost);
NewsItem newsItem = new NewsItem(NewsType.Blog, blogPost.UrlFriendlyTitle, blogPost.Title, postAnnounementTitle, blogHtml, blogPost.InternalHttpPath, blogPost.CreatedDate, blogPost.PublishDate);
news.Add(newsItem);
var newsFeedItem = new SyndicationItem(blogPost.Title, blogPost.PostExternalHtml, new Uri(blogPost.ExternalHttpPath), blogPost.UrlFriendlyTitle, blogPost.CreatedDate);
newsFeedItem.PublishDate = newsItem.CreatedDate;
this.FeedItems.Add(newsFeedItem);
}
// Order the news by creation date.
this.News = news.Where(n => !n.PublishDate.HasValue || n.PublishDate.Value < DateTime.Now).OrderByDescending(n => n.CreatedDate);
this.BlogPosts = blogPosts.Where(b=>!b.PublishDate.HasValue || b.PublishDate.Value < DateTime.Now).OrderByDescending(n => n.CreatedDate);
}
示例14: SummateProducts
private static Collection<MixERP.Net.Common.Models.Transactions.ProductDetailsModel> SummateProducts(Collection<MixERP.Net.Common.Models.Transactions.ProductDetailsModel> productCollection)
{
//Create a new collection of products.
Collection<MixERP.Net.Common.Models.Transactions.ProductDetailsModel> collection = new Collection<Common.Models.Transactions.ProductDetailsModel>();
//Iterate through the supplied product collection.
foreach (MixERP.Net.Common.Models.Transactions.ProductDetailsModel product in productCollection)
{
//Create a product
MixERP.Net.Common.Models.Transactions.ProductDetailsModel productInCollection = null;
if (collection.Count > 0)
{
productInCollection = collection.Where(x => x.ItemCode == product.ItemCode && x.ItemName == product.ItemName && x.Unit == product.Unit && x.Price == product.Price && x.Rate == product.Rate).FirstOrDefault();
}
if (productInCollection == null)
{
collection.Add(product);
}
else
{
productInCollection.Quantity += product.Quantity;
productInCollection.Amount += product.Amount;
productInCollection.Discount += product.Discount;
productInCollection.Subtotal += product.Subtotal;
productInCollection.Tax += product.Tax;
productInCollection.Total += product.Total;
}
}
return collection;
}
示例15: CopyMappings
private static Collection<KeyMapping> CopyMappings(Collection<KeyMapping> keyMappings)
{
var copy = new Collection<KeyMapping>();
foreach (KeyMapping map in keyMappings.Where(map => map.IsValid()))
{
copy.Add(map);
}
return copy;
}