本文整理汇总了C#中Model.List.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# List.OrderBy方法的具体用法?C# List.OrderBy怎么用?C# List.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.OrderBy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertNestedCategoriesAreOrderedRight
internal static void AssertNestedCategoriesAreOrderedRight(this HierachyCategoryPages page, List<Categories> listOfNestedCategories)
{
listOfNestedCategories = listOfNestedCategories.OrderBy(x => x.Order).ToList();
for (int i = 0; i < listOfNestedCategories.Count; i++)
{
Assert.AreEqual(listOfNestedCategories[i].Name, page.NestedListWithCategories.ChildNodes[i].InnerText);
}
}
示例2: ScheduleTalks
/// <summary>
/// Schedules the talks for the given duration.
/// </summary>
/// <param name="unscheduledTalks">The unscheduled talks.</param>
/// <param name="duration">The duration.</param>
/// <returns>
/// List of scheduled talks.
/// </returns>
public List<ITalk> ScheduleTalks(List<ITalk> unscheduledTalks, int duration)
{
_result = null; //If a subset is found this will not be null.
const int sum = 0;
const int startIndex = 0;
var talks = unscheduledTalks.OrderBy(talk => talk.Duration).ToList();
int remainder = talks.Sum(talk => talk.Duration);
ScheduleTalks(talks, duration, sum, startIndex, remainder);
return _result;
}
示例3: GetAllRedactors
public static List<AspNetUsers> GetAllRedactors(AspNetUsers user)
{
List<AspNetUsers> Allredactors = new List<AspNetUsers>();
var redactorsListFromTableRedactors = RedactorsRepository.FindAll(r => r.Administrator_Id == user.Id).GroupBy(a => a.UserId_Id).Select(g => g.First()).OrderBy(i => i.UserId_Id).ToList();
if (redactorsListFromTableRedactors != null)
{
foreach (var redactor in redactorsListFromTableRedactors)
{
Allredactors.Add(UsersRepository.Find(u => u.Id == redactor.UserId_Id));
}
return Allredactors.OrderBy(u => u.Email).ToList();
}
else
return null;
}
示例4: MainViewModel
public MainViewModel()
{
// please adjust this to meet your system layout ...
// obviously this should be changed to load file dialog usage :)
try
{
_movies = DataLoader.ReadItemLabels("u.item");
_trainData = DataLoader.ReadTrainingData("u.data");
}
catch (Exception)
{
MessageBox.Show("Error loading data files! Please check ViewModel.cs for file location!", "Error loading files", MessageBoxButton.OK, MessageBoxImage.Error);
Application.Current.Shutdown();
}
Movies = new ObservableCollection<Movie>(_movies.OrderBy(m=>m.Title));
NewRank = 1;
RaisePropertyChanged(() => NewRank);
SelectedMovie = Movies.First();
RaisePropertyChanged(() => SelectedMovie);
Ranking = new Dictionary<int, int>();
AddRankCommand = new RelayCommand(() => {
if (!Ranking.ContainsKey(SelectedMovie.Id)) {
Log += string.Format("{0} - rank: {1}\n", SelectedMovie, NewRank);
RaisePropertyChanged(() => Log);
Ranking.Add(SelectedMovie.Id, NewRank);
Movies.Remove(SelectedMovie);
SelectedMovie = Movies.First();
RaisePropertyChanged(() => SelectedMovie);
}
var rec = Engine.GetRecommendations(_movies, Ranking, _trainData);
var foo = rec.OrderByDescending(e => e.Rank);//.Where(e => !Ranking.ContainsKey(e.Id));
Recomendations =new ObservableCollection<Movie>(foo);
this.RaisePropertyChanged(() => Recomendations);
});
}
示例5: Carrega
private void Carrega()
{
listProcedures.DataSource = _objProcBO.GetProcView("sys.procedures");
listProcedures.DisplayMember = "name";
listProcedures.ValueMember = "name";
listView.DataSource = _objProcBO.GetProcView("sys.views");
listView.DisplayMember = "name";
listView.ValueMember = "name";
listTriggers.DataSource = _objProcBO.GetProcView("sys.triggers");
listTriggers.DisplayMember = "name";
listTriggers.ValueMember = "name";
lConstraints = new List<constraintsModel>();
lConstraints = objConstrBo.GetAllConstraints();
listConstraints.Items.Clear();
foreach (var item in lConstraints.OrderBy(c => c.sConstrName))
{
listConstraints.Items.Add(item: item.sConstrName.ToString());
}
listProcedures_Click(this, null);
}
示例6: Load
public IEnumerator Load()
{
DebugLog("+Load()");
var pyriteQuery = new PyriteQuery(this, SetName, ModelVersion, PyriteServer);
yield return StartCoroutine(pyriteQuery.LoadAll());
DebugLog("CubeQuery complete.");
var pyriteLevel =
pyriteQuery.DetailLevels[DetailLevel];
var allOctCubes = pyriteQuery.DetailLevels[DetailLevel].Octree.AllItems();
foreach (var octCube in allOctCubes)
{
var pCube = CreateCubeFromCubeBounds(octCube);
var x = pCube.X;
var y = pCube.Y;
var z = pCube.Z;
var cubePos = pyriteLevel.GetWorldCoordinatesForCube(pCube);
if (UseCameraDetection)
{
// Move cube to the orientation we want also move it up since the model is around -600
var g =
(GameObject)
//Instantiate(PlaceHolderCube, new Vector3(-cubePos.x, cubePos.z + 600, -cubePos.y),
//Instantiate(PlaceHolderCube, new Vector3(-cubePos.x, cubePos.z, -cubePos.y),
Instantiate(PlaceHolderCube, new Vector3(cubePos.x, cubePos.y, cubePos.z),
Quaternion.identity);
//var loc = Instantiate(LocatorCube, new Vector3(cubePos.x, cubePos.y, cubePos.z), Quaternion.identity) as GameObject;
var loc = Instantiate(LocatorCube, cubePos, Quaternion.identity) as GameObject;
loc.transform.parent = gameObject.transform;
g.transform.parent = gameObject.transform;
//g.GetComponent<MeshRenderer>().material.color = _colorList[_colorSelector%_colorList.Length];
g.GetComponent<IsRendered>().SetCubePosition(x, y, z, DetailLevel, pyriteQuery, this);
g.transform.localScale = new Vector3(
pyriteLevel.WorldCubeScale.x,
pyriteLevel.WorldCubeScale.z,
pyriteLevel.WorldCubeScale.y);
_colorSelector++;
}
else
{
var loadRequest = new LoadCubeRequest(x, y, z, DetailLevel, pyriteQuery, null);
EnqueueLoadCubeRequest(loadRequest);
}
}
if (CameraRig != null)
{
//DebugLog("Moving camera");
// Hardcoding some values for now
//var min = new Vector3(pyriteLevel.ModelBoundsMin.x, pyriteLevel.ModelBoundsMin.y,
// pyriteLevel.ModelBoundsMin.z);
//var max = new Vector3(pyriteLevel.ModelBoundsMax.x, pyriteLevel.ModelBoundsMax.y,
// pyriteLevel.ModelBoundsMax.z);
//min += pyriteLevel.WorldCubeScale/2;
//max -= pyriteLevel.WorldCubeScale/2;
//var newCameraPosition = min + (max - min)/2.0f;
//newCameraPosition += new Vector3(0, 0, (max - min).z*1.4f);
//CameraRig.transform.position = newCameraPosition;
//CameraRig.transform.rotation = Quaternion.Euler(0, 180, 0);
//DebugLog("Done moving camera");
//var delta = pyriteLevel.ModelBoundsMax - pyriteLevel.ModelBoundsMin;
//var center = pyriteLevel.ModelBoundsMin + new Vector3(-delta.x / 2, delta.z /2 , -delta.y);
//CameraRig.transform.position = center;
//var allOctCubes = pyriteQuery.DetailLevels[DetailLevel].Octree.AllItems();
// RPL CONVERSION
List<GridPos> gList = new List<GridPos>();
Dictionary<string, CubeBounds> gDict = new Dictionary<string, CubeBounds>();
foreach (var octCube in allOctCubes)
{
var pCube = CreateCubeFromCubeBounds(octCube);
var x = pCube.X;
var y = pCube.Y;
var z = pCube.Z;
var gPos = new GridPos(x, y, z);
gList.Add(gPos);
gDict.Add(gPos.ToKeyString(), octCube);
}
int midIndex = gList.Count / 2;
var gMid = gList.OrderBy(n => n.x).ThenBy(n => n.y).ThenBy(n => n.z).ToList()[midIndex];
var cubeBound = CreateCubeFromCubeBounds(gDict[gMid.ToKeyString()]);
var cubeVector3 = pyriteLevel.GetWorldCoordinatesForCube(cubeBound);
CameraRig.transform.position = cubeVector3;
var r = Instantiate(LocatorCube, cubeVector3, Quaternion.identity) as GameObject;
//.........这里部分代码省略.........
示例7: ProceedInput
/// <summary>
/// proceed input
/// </summary>
/// <param name="inputList"></param>
public List<string> ProceedInput(string[] inputList,string reportType)
{
//transfer input to model
List<InputReportModel> inputRepModels = new List<InputReportModel>();
List<OutputReportModel> outputRepModel = new List<OutputReportModel>();
List<string> Output = new List<string>();
int count = 1;
foreach (var item in inputList)
{
string[] input = item.Split('\t');
inputRepModels.Add(
new InputReportModel
{
CaseSeq = count++,
EditCaption = input[0],
DeleteCaption = input[1],
StartHour = Get24HourFormat(input[2]),
EndHour = Get24HourFormat(input[3]),
FBId = Int64.Parse(input[4]),
Description = input[5]
}
);
}
//process output (count man hour)
foreach (var item in inputRepModels.OrderBy(x => x.CaseSeq))
{
outputRepModel.Add
(
new OutputReportModel
{
CaseSeq = item.CaseSeq,
FBId = item.FBId,
Description = item.Description,
ManHour = SubstractTime(item.StartHour, item.EndHour)
}
);
}
//group by fb id
var groupOutput = (from O in outputRepModel
group O by O.FBId into G
select new OutputReportModel
{
CaseSeq = G.First().CaseSeq,
FBId = G.First().FBId,
Description = G.First().Description,
ManHour = G.Sum(x => x.ManHour)
}).OrderBy(x => x.CaseSeq).ToList();
//create output
int auto = 1;
double totalManHour = 0;
foreach (var item in groupOutput)
{
if (reportType == C.Constant.MitraisReport)
{
totalManHour += item.ManHour;
Output.Add((auto++).ToString() + '\t' + '[' + item.FBId + "] " + item.Description + '\t' + item.ManHour + System.Environment.NewLine);
}
else
{
string clientName = item.Description.Split(C.Constant.FbDescDelimeter)[0];
string fBCompleteLink = C.Constant.FBLink + item.FBId.ToString();
Output.Add(clientName + '\t' + fBCompleteLink + System.Environment.NewLine);
}
}
Output.Add(System.Environment.NewLine + System.Environment.NewLine);
Output.Add("Total Man Hour =" + totalManHour);
return Output;
}
示例8: Activate
//.........这里部分代码省略.........
});
// Anaerobic
loHeartRateZones.Add(new HeartRateZoneItem()
{
Key = HeartRateZoneItem.HRZONE_ANAEROBIC,
Name = Resources.Strings.TextHeartRateZoneAnaerobicText,
Value = Activity.PerformanceSummary.HeartRateZones.Anaerobic ?? 0,
});
// Redline
loHeartRateZones.Add(new HeartRateZoneItem()
{
Key = HeartRateZoneItem.HRZONE_REDLINE,
Name = Resources.Strings.TextHeartRateZoneRedlineText,
Value = Activity.PerformanceSummary.HeartRateZones.Redline ?? 0,
});
// OverRedline
loHeartRateZones.Add(new HeartRateZoneItem()
{
Key = HeartRateZoneItem.HRZONE_OVER_REDLINE,
Name = Resources.Strings.TextHeartRateZoneOverRedlineText,
Value = Activity.PerformanceSummary.HeartRateZones.OverRedline ?? 0,
});
HeartRateZones = new ObservableCollection<HeartRateZoneItem>(loHeartRateZones);
IsHeartRateZonesAvailable = true;
}
// Segments (splits)
if (Activity.ActivitySegments != null &&
Activity.ActivitySegments.Any() &&
TotalDistance != null)
{
// ActivitySegment to Split
double ldSplitValue = 0;
List<SplitItem> loSplits = new List<SplitItem>();
foreach (MSHealthActivitySegment loSegment in Activity.ActivitySegments.OrderBy(loSeg => loSeg.StartTime))
{
ldSplitValue++;
loSplits.Add(new SplitItem()
{
Value = ldSplitValue > (double)TotalDistance.Value ? (double)TotalDistance.Value : ldSplitValue,
Duration = loSegment.Duration.Value,
AvgHeartRate = loSegment.HeartRateSummary != null ? loSegment.HeartRateSummary.AverageHeartRate.Value : 0,
});
}
// Get Max/Min Duration/HR, for complete splits only
try
{
loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderBy(loSplit => loSplit.Duration).First().DurationMark = "↓";
loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderByDescending(loSplit => loSplit.Duration).First().DurationMark = "↑";
loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderBy(loSplit => loSplit.AvgHeartRate).First().HRMark = "↓";
loSplits.Where(loSplit => (loSplit.Value % 1) == 0).OrderByDescending(loSplit => loSplit.AvgHeartRate).First().HRMark = "↑";
}
catch { /* Do nothing */ }
// Sort by value and assign to instance
loSplits = loSplits.OrderBy(loSplit => loSplit.Value).ToList();
Splits = new ObservableCollection<SplitItem>(loSplits);
}
// MapPoints to MapPath
if (Activity.MapPoints != null &&
Activity.MapPoints.Any())
{
List<BasicGeoposition> loGeopositions = new List<BasicGeoposition>();
loGeopositions = (from loMapPoint in Activity.MapPoints
.Where(loPoint => loPoint.Location != null &&
loPoint.Location.Latitude != null &&
loPoint.Location.Longitude != null)
.OrderBy(loPoint => loPoint.Ordinal)
示例9: GetLanguages
/// <summary>
/// Gets a list of all available languages.
/// </summary>
/// <param name="mirror">Mirror to use.</param>
/// <returns>Collection of all available languages.</returns>
/// <example>Shows how to get all languages.
/// <code>
/// namespace Docunamespace
/// {
/// /// <summary>
/// /// Class for the docu.
/// /// </summary>
/// class DocuClass
/// {
/// /// <summary>
/// /// Gets all mirrors that are available.
/// /// </summary>
/// public List<Language> GetAllLanguages(Mirror mirror)
/// {
/// string apiKey = "ABCD12345";
/// TVDB.Web.ITvDb instance = new TVDB.Web.WebInterface(apiKey);
/// List<Language> languages = await instance.GetLanguages(mirror);
///
/// return languages
/// }
/// }
/// }
/// </code>
/// </example>
public async Task<List<Language>> GetLanguages(Mirror mirror)
{
if (mirror == null)
{
return null;
}
string url = "{0}/api/{1}/languages.xml";
byte[] result = await this.client.DownloadDataTaskAsync(string.Format(url, mirror.Address, APIKey)).ConfigureAwait(continueOnCapturedContext: false);
MemoryStream resultStream = new MemoryStream(result);
XmlDocument doc = new XmlDocument();
doc.Load(resultStream);
XmlNode dataNode = doc.ChildNodes[1];
List<Language> receivedLanguages = new List<Language>();
foreach (XmlNode currentNode in dataNode.ChildNodes)
{
Language deserialized = new Language();
deserialized.Deserialize(currentNode);
receivedLanguages.Add(deserialized);
}
return receivedLanguages.OrderBy(x => x.Name).ToList<Language>();
}
示例10: SelectDay
private void SelectDay()
{
DateTime now = new DateTime(int.Parse(this.YearDropDownList.SelectedValue), int.Parse(this.MonthDropDownList.SelectedValue), 1);
List<int> days = new List<int>(31);
for (int i = 1; i <= DateTime.DaysInMonth(now.Year, now.Month); i++)
{
days.Add(i);
}
this.DayDropDownList.DataSource = days.OrderBy(d => d);
this.DayDropDownList.DataBind();
}