本文整理汇总了C#中IOrderedEnumerable类的典型用法代码示例。如果您正苦于以下问题:C# IOrderedEnumerable类的具体用法?C# IOrderedEnumerable怎么用?C# IOrderedEnumerable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IOrderedEnumerable类属于命名空间,在下文中一共展示了IOrderedEnumerable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColorGraphAndGetColorCount
/// <summary>
/// Colors the graph and returns the number of colors needed
/// </summary>
private static int ColorGraphAndGetColorCount(IOrderedEnumerable<Node> sortedRepeaters )
{
int maxColor = 0;
foreach(Node node in sortedRepeaters)
{
int minColorNotUsed = 0;
List<int> colorsUsed = new List<int>();
foreach (Node adjacentNode in node.AdjacentNodes)
{
if (adjacentNode.Color != -1)
colorsUsed.Add(adjacentNode.Color);
}
//its a planar graph so no more than 4 colors needed
for (int i = 0; i <=3; i ++)
{
if (!colorsUsed.Contains(i))
{
minColorNotUsed = i;
break;
}
}
//now we have the minimum color not used by adjacent nodes, color the node
node.Color = minColorNotUsed;
if (minColorNotUsed > maxColor)
maxColor = minColorNotUsed;
}
return maxColor+1;
}
示例2: ProtocolReport
public ProtocolReport(ReportModel model)
: base(model, "ProtocolTemplate.docx")
{
this.modelItems = ReportModel.ReportParameters["ProtocolResults"] as IOrderedEnumerable<ProtocolResult>;
this.hasMKB = this.modelItems.Any(pr => pr.ProductTest.Test.TestType.ShortName == TestTypes.MKB);
this.hasFZH = this.modelItems.Any(pr => pr.ProductTest.Test.TestType.ShortName == TestTypes.FZH);
}
示例3: CreateSuitesXElementWithParameters
public XElement CreateSuitesXElementWithParameters(
IOrderedEnumerable<ITestSuite> suites,
IOrderedEnumerable<ITestScenario> scenarios,
IOrderedEnumerable<ITestResult> testResults,
IXMLElementsStruct xmlStruct)
{
var suitesElement =
new XElement(xmlStruct.SuitesNode,
from suite in suites
select new XElement(xmlStruct.SuiteNode,
new XAttribute("uniqueId", suite.UniqueId),
new XAttribute("id", suite.Id),
new XAttribute("name", suite.Name),
new XAttribute("status", suite.Status),
createXattribute(xmlStruct.TimeSpentAttribute, Convert.ToInt32(suite.Statistics.TimeSpent)),
new XAttribute("all", suite.Statistics.All.ToString()),
new XAttribute("passed", suite.Statistics.Passed.ToString()),
createXattribute(xmlStruct.FailedAttribute, suite.Statistics.Failed.ToString()),
new XAttribute("notTested", suite.Statistics.NotTested.ToString()),
new XAttribute("knownIssue", suite.Statistics.PassedButWithBadSmell.ToString()),
createXattribute("description", suite.Description),
createXattribute("platformId", suite.PlatformId),
createXattribute("platformUniqueId", suite.PlatformUniqueId),
CreateScenariosXElementCommon(
suite,
// 20141122
// scenarios.Where(scenario => scenario.SuiteId == suite.Id).OrderBy(scenario => scenario.Id),
// testResults.Where(testResult => testResult.SuiteId == suite.Id).OrderBy(testResult => testResult.Id),
scenarios.Where(scenario => scenario.SuiteId == suite.Id && scenario.SuiteUniqueId == suite.UniqueId).OrderBy(scenario => scenario.Id),
testResults.Where(testResult => testResult.SuiteId == suite.Id && testResult.SuiteUniqueId == suite.UniqueId).OrderBy(testResult => testResult.Id),
xmlStruct)
)
);
return suitesElement;
}
示例4: Print
static void Print(IOrderedEnumerable<List<int>> sortedResults)
{
foreach (var item in sortedResults)
{
Console.WriteLine("{0} = {1}", string.Join(" + ", item), endResult);
}
}
示例5: Percentile
private double Percentile(IOrderedEnumerable<double> sortedData, double p)
{
int count = sortedData.Count();
if (count == 0) return 0;
if (count == 1) return sortedData.Last();
if (p >= 100.0d) return sortedData.Last();
double position = (count + 1) * p / 100d;
double leftNumber, rightNumber;
double n = p / 100d * (count - 1) + 1d;
if (position >= 1)
{
leftNumber = sortedData.ElementAt((int)Math.Floor(n) - 1);
rightNumber = sortedData.ElementAt((int)Math.Floor(n));
}
else
{
leftNumber = sortedData.First();
rightNumber = sortedData.ElementAt(1);
}
if (Math.Abs(leftNumber - rightNumber) < Double.Epsilon)
return leftNumber;
else
{
double part = n - Math.Floor(n);
return leftNumber + part*(rightNumber - leftNumber);
}
}
示例6: GetMatchedRecords
protected virtual bool GetMatchedRecords(
IOrderedEnumerable<IRecord> recordsFilteredByDate,
IModelInput modelInput,
out IDictionary<string, IList<IRecord>> matchedRecords
)
{
matchedRecords = new Dictionary<string, IList<IRecord>>();
if (!recordsFilteredByDate.AnySave())
{
return false;
}
foreach (var record in recordsFilteredByDate)
{
foreach (var term in modelInput.FilterTerms)
{
var distinctMatchedDescription = GetMatchedDistinctDescription(record.Description, term);
record.DistinctDescription = distinctMatchedDescription;
if (string.IsNullOrEmpty(distinctMatchedDescription))
{
continue;
}
if (matchedRecords.ContainsKey(distinctMatchedDescription))
{
matchedRecords[distinctMatchedDescription].Add(record);
}
else
{
matchedRecords.Add(distinctMatchedDescription, new List<IRecord>() { record });
}
break;
}
}
return matchedRecords.Any();
}
示例7: ReplaceForbbidenWords
public static StringBuilder ReplaceForbbidenWords(string text, IOrderedEnumerable<KeyValuePair<string, List<int>>> sortedLocations)
{
const char STAR_SYMBOL = '*';
StringBuilder result = new StringBuilder();
int index = 0;
foreach (var forbiddenWord in sortedLocations)
{
foreach (var location in forbiddenWord.Value)
{
for (; index < text.Length; index++)
{
if (index >= location && index < location + forbiddenWord.Key.Length)
{
result.Append(STAR_SYMBOL);
}
else
{
result.Append(text[index]);
}
if (index == location + forbiddenWord.Key.Length)
{
break;
}
}
}
}
return result;
}
示例8: DisplayPackageViewModel
public DisplayPackageViewModel(Package package, IOrderedEnumerable<Package> packageHistory, bool isVersionHistory)
: base(package)
{
Copyright = package.Copyright;
if (!isVersionHistory)
{
Dependencies = new DependencySetsViewModel(package.Dependencies);
PackageVersions = packageHistory.Select(p => new DisplayPackageViewModel(p, packageHistory, isVersionHistory: true));
}
DownloadCount = package.DownloadCount;
LastEdited = package.LastEdited;
if (!isVersionHistory && packageHistory.Any())
{
// calculate the number of days since the package registration was created
// round to the nearest integer, with a min value of 1
// divide the total download count by this number
TotalDaysSinceCreated = Convert.ToInt32(Math.Max(1, Math.Round((DateTime.UtcNow - packageHistory.Last().Created).TotalDays)));
DownloadsPerDay = TotalDownloadCount / TotalDaysSinceCreated; // for the package
}
else
{
TotalDaysSinceCreated = 0;
DownloadsPerDay = 0;
}
}
示例9: GetTotalInventory
/// <summary>
/// Get Total list of items in the inventory
/// </summary>
/// <param name="lstTotalInventoryMl"></param>
/// <param name="lstInventoryMl"></param>
private List<InventoryModel> GetTotalInventory(IOrderedEnumerable<InventoryModel> lstTotalInventoryMl, string logicalDeviceId, string searchText)
{
List<InventoryModel> lstInventoryMl = new List<InventoryModel>();
var lstInventoryInMl =
lstTotalInventoryMl.Where(x => x.CurrentState.Equals(Enums.CurrentState.Add.ToString())).ToList();
var lstInventoryOutMl =
lstTotalInventoryMl.Where(x => x.CurrentState.Equals(Enums.CurrentState.Remove.ToString())).ToList();
foreach (var inventoryInMl in lstInventoryInMl)
{
var inventoryOutMl =
lstInventoryOutMl.Where(
x => x.LogicalDeviceId == inventoryInMl.LogicalDeviceId && x.TagEPC == inventoryInMl.TagEPC)
.ToList();
if (inventoryOutMl.Count == 0)
{
lstInventoryMl.Add(inventoryInMl);
}
else
{
lstInventoryOutMl.Remove(inventoryOutMl.FirstOrDefault());
}
}
lstInventoryMl.ToList().ForEach(x =>
{
x.Batch = (from u in ObjTersoDataContext.items
where u.EPC == x.TagEPC
select u.Batch).FirstOrDefault();
x.ItemId = (from u in ObjTersoDataContext.items
where u.EPC == x.TagEPC
select u.ItemId).FirstOrDefault();
x.Material = (from u in ObjTersoDataContext.items
where u.EPC == x.TagEPC
select u.Material).FirstOrDefault();
x.ExpirationDate = (from u in ObjTersoDataContext.items
where u.EPC == x.TagEPC
select u.ExpirationDate).FirstOrDefault();
x.ExpirationDateString = x.ExpirationDate != null ? String.Format("{0:MM/dd/yyyy}", x.ExpirationDate.Value) : string.Empty;
x.DeviceId = (from u in ObjTersoDataContext.devices
where u.LogicalDeviceId == x.LogicalDeviceId
select u.DeviceId).FirstOrDefault();
});
lstInventoryMl = lstInventoryMl.Where(x => (string.IsNullOrEmpty(logicalDeviceId) || x.LogicalDeviceId.Equals(logicalDeviceId))
&& (string.IsNullOrEmpty(searchText) ||
(!string.IsNullOrEmpty(x.Material) && x.Material.Contains(searchText)) ||
(!string.IsNullOrEmpty(x.Batch) && x.Batch.Contains(searchText)) ||
x.TagEPC.Contains(searchText) || x.LogicalDeviceId.Equals(searchText)
)).ToList();
lstInventoryMl.ToList().ForEach(x =>
{
x.TotalRows = lstInventoryMl.Count;
});
return lstInventoryMl.ToList();
}
示例10: BurrowsWheelerTransform
internal BurrowsWheelerTransform(IOrderedEnumerable<int[]> transform)
{
var y = transform.Select(v => new { F = v[0], L = v[2], S = v[1] }).ToArray();
sorted = y.Select(v => v.F).ToArray();
bwt = y.Select(v => v.L).ToArray();
suffix = y.Select(v => v.S).ToArray();
index = suffix.Select((s, i) => new { S = s, I = i }).OrderBy(v => v.S).Select(v => v.I).ToArray();
}
示例11: Print
private static void Print(IOrderedEnumerable<A> result)
{
var output = result.Select(a =>
{
Console.WriteLine(a.S);
return a.S;
});
}
示例12: PrintList
private static void PrintList(IOrderedEnumerable<Worker> list)
{
foreach (var human in list)
{
Console.WriteLine(human);
}
Console.WriteLine();
}
示例13: MeansOfTransportAsString
public string MeansOfTransportAsString(IOrderedEnumerable<TransportMethod> meansOfTransport)
{
if (meansOfTransport == null || !meansOfTransport.Any())
{
return string.Empty;
}
return string.Join("-", meansOfTransport.Select(m => EnumHelper.GetShortName(m)));
}
示例14: GatherCollections
public void GatherCollections(ISearchCmdletBaseDataObject searchCriteria, List<ITestSuite> suitesForSearch)
{
var testResultsSearcher = new TestResultsSearcher();
TestSuites = testResultsSearcher.SearchForSuites(searchCriteria, suitesForSearch);
TestScenarios = testResultsSearcher.SearchForScenarios(searchCriteria, suitesForSearch);
TestResults = testResultsSearcher.SearchForTestResults(searchCriteria, suitesForSearch);
}
示例15: ZapperProcessor
public ZapperProcessor(FileZapperSettings settings = null, IList<IZapperPhase> phases = null)
{
_log.Info("Initializing");
ZapperFiles = new ConcurrentDictionary<string, ZapperFile>();
ZapperFilesDeleted = new ConcurrentDictionary<string, ZapperFileDeleted>();
if (settings == null)
{
settings = new FileZapperSettings();
settings.Load();
}
Settings = settings;
if (phases != null)
{
foreach (var phase in phases) { phase.ZapperProcessor = this; }
_phases = phases.OrderBy(x => x.PhaseOrder);
}
else
{
List<IZapperPhase> allphases = new List<IZapperPhase>();
allphases.Add(new PhaseCleanup { PhaseOrder = 1, ZapperProcessor = this, IsInitialPhase = true });
allphases.Add(new PhaseParseFilesystem { PhaseOrder = 2, ZapperProcessor = this });
allphases.Add(new PhaseCalculateSamples { PhaseOrder = 3, ZapperProcessor = this });
allphases.Add(new PhaseCalculateHashes { PhaseOrder = 4, ZapperProcessor = this });
allphases.Add(new PhaseRemoveDuplicates { PhaseOrder = 5, ZapperProcessor = this });
_phases = allphases.OrderBy(x => x.PhaseOrder);
}
}