本文整理汇总了C#中EntityCollection.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# EntityCollection.OrderBy方法的具体用法?C# EntityCollection.OrderBy怎么用?C# EntityCollection.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityCollection
的用法示例。
在下文中一共展示了EntityCollection.OrderBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LinkifiedText
internal static string LinkifiedText(EntityCollection entities, string text)
{
if (entities == null || entities.Count == 0)
{
return text;
}
string linkedText = text;
var entitiesSorted = entities.OrderBy(e => e.StartIndex).Reverse();
foreach (Entity entity in entitiesSorted)
{
if (entity is HashTagEntity)
{
HashTagEntity tagEntity = (HashTagEntity)entity;
linkedText = string.Format(
"{0}<a href=\"http://twitter.com/search?q=%23{1}\">{1}</a>{2}",
linkedText.Substring(0, entity.StartIndex),
tagEntity.Text,
linkedText.Substring(entity.EndIndex));
}
if (entity is UrlEntity)
{
UrlEntity urlEntity = (UrlEntity)entity;
linkedText = string.Format(
"{0}<a href=\"{1}\">{1}</a>{2}",
linkedText.Substring(0, entity.StartIndex),
urlEntity.Url,
linkedText.Substring(entity.EndIndex));
}
if (entity is MentionEntity)
{
MentionEntity mentionEntity = (MentionEntity)entity;
linkedText = string.Format(
"{0}<a href=\"http://twitter.com/{1}\">@{1}</a>{2}",
linkedText.Substring(0, entity.StartIndex),
mentionEntity.ScreenName,
linkedText.Substring(entity.EndIndex));
}
}
return linkedText;
}
示例2: TestOrderByOperator
public void TestOrderByOperator()
{
EntityCollection<TestAccountEntity> entities = new EntityCollection<TestAccountEntity>();
entities.Add(new TestAccountEntity(100, 5));
entities.Add(new TestAccountEntity(102, 8));
entities.Add(new TestAccountEntity(103, 15));
entities.Add(new TestAccountEntity(104, 2));
IEnumerable<TestAccountEntity> result =
entities.OrderBy<long>(
delegate(TestAccountEntity entity)
{
return entity.Amount;
});
Assert.IsNotNull(result);
foreach (TestAccountEntity entity in result)
{
Assert.IsNotNull(entity);
Console.WriteLine(entity);
}
}