当前位置: 首页>>代码示例>>C#>>正文


C# Random.NextDictionaryPair方法代码示例

本文整理汇总了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);
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:28,代码来源:PatientTherapyBuilder.cs

示例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;
        }
开发者ID:ryanpeelman,项目名称:EMRG,代码行数:18,代码来源:PatientLabBuilder.cs


注:本文中的System.Random.NextDictionaryPair方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。