本文整理汇总了C#中System.Random.NextDictionaryPair方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NextDictionaryPair方法的具体用法?C# Random.NextDictionaryPair怎么用?C# Random.NextDictionaryPair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.NextDictionaryPair方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPatientTherapies
public IEnumerable<PatientTherapy> GetPatientTherapies(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientTherapies)
{
fixture.Customize<PatientTherapy>(pt => pt.With(x => x.PatientId, demographic.PatientId)
.Without(x => x.DDID)
.Without(x => x.RXNorm)
.Without(x => x.StopDate));
var therapies = fixture.CreateMany<PatientTherapy>(randomizer.Next(0, maxNumberOfPatientTherapies + 1));
foreach (var therapy in therapies)
{
var daysOnTherapy = randomizer.Next(1, 365);
therapy.StopDate = new DateTime(Math.Min(therapy.StartDate.AddDays(daysOnTherapy).Ticks, DateTime.Now.Ticks));
var hasFavoredTherapy = randomizer.NextPercent() <= ChanceOfHavingFavoredCondition;
if (hasFavoredTherapy)
{
var pair = randomizer.NextDictionaryPair(_favoredTherapies);
therapy.NDC = pair.Key;
therapy.DrugName = pair.Value;
}
else
{
therapy.NDC = NDCGenerator.GetRandomNDC(randomizer);
}
}
return therapies.OrderBy(x => x.StartDate);
}
示例2: GetPatientLabs
public IEnumerable<PatientLab> GetPatientLabs(Fixture fixture, Random randomizer, PatientDemographics demographic, int maxNumberOfPatientLabs)
{
fixture.Customize<PatientLab>(pl => pl.With(x => x.PatientId, demographic.PatientId));
var labs = fixture.CreateMany<PatientLab>(randomizer.Next(0, maxNumberOfPatientLabs + 1)).OrderBy(x => x.LabDate);
foreach (var lab in labs)
{
var hasFavoredLab = randomizer.NextPercent() <= ChanceOfHavingFavoredLab;
if (hasFavoredLab)
{
var pair = randomizer.NextDictionaryPair(_favoredLabs);
lab.LabName = pair.Key.Replace("[NORMAL]", string.Empty).Replace("[ABNORMAL]", string.Empty);
lab.Value = pair.Value.Invoke(randomizer);
}
}
return labs;
}