本文整理汇总了C#中Edu.Wisc.Forest.Flel.Util.Percentage类的典型用法代码示例。如果您正苦于以下问题:C# Percentage类的具体用法?C# Percentage怎么用?C# Percentage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Percentage类属于Edu.Wisc.Forest.Flel.Util命名空间,在下文中一共展示了Percentage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoubleCtor
public void DoubleCtor()
{
Percentage percentage = new Percentage(0.567);
Assert.AreEqual(0.567, percentage.Value);
Assert.AreEqual(0.567, (double) percentage);
Assert.AreEqual("56.7%", percentage.ToString());
}
示例2: AgeOrRangeWasRead
//---------------------------------------------------------------------
public static void AgeOrRangeWasRead(AgeRange ageRange,
Percentage percentage)
{
ageOrRangeWasRead = true;
// Have we started reading ages and ranges for another species?
// If so, then first clear the old values from the previous
// species.
if (ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] == null)
{
ages.Clear();
ranges.Clear();
percentages.Clear();
}
if (ageRange.Start == ageRange.End)
ages.Add(ageRange.Start);
else
ranges.Add(ageRange);
if (percentage != null)
percentages[ageRange.Start] = percentage;
if (HarvestSpeciesDataset.MostRecentlyFetchedSpecies != null)
ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] = new SpecificAgesCohortSelector(ages, ranges, percentages);
currentSpecies = HarvestSpeciesDataset.MostRecentlyFetchedSpecies;
}
示例3: DefaultCtor
public void DefaultCtor()
{
Percentage percentage = new Percentage();
Assert.AreEqual(0.0, percentage.Value);
Assert.AreEqual(0.0, (double) percentage);
Assert.AreEqual("0%", percentage.ToString());
}
示例4: AgeOrRangeWasRead
//---------------------------------------------------------------------
public static void AgeOrRangeWasRead(AgeRange ageRange,
Percentage percentage)
{
ageOrRangeWasRead = true;
// Have we started reading ages and ranges for another species?
// If so, then first clear the old values from the previous
// species.
bool clearOldValues = (HarvestSpeciesDataset.MostRecentlyFetchedSpecies != null) &&
(ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] == null);
if (clearOldValues)
{
ages.Clear();
ranges.Clear();
percentages.Clear();
}
if (ageRange.Start == ageRange.End)
ages.Add(ageRange.Start);
else
ranges.Add(ageRange);
if (percentage != null)
percentages[ageRange.Start] = percentage;
if (Landis.Extension.BaseHarvest.InputParametersParser.AllSpeciesNameWasRead)
ageSelectorForAllSpecies = new SpecificAgesCohortSelector(ages, ranges, percentages);
if (HarvestSpeciesDataset.MostRecentlyFetchedSpecies != null)
ageSelectors[HarvestSpeciesDataset.MostRecentlyFetchedSpecies.Index] = new SpecificAgesCohortSelector(ages, ranges, percentages);
currentSpecies = HarvestSpeciesDataset.MostRecentlyFetchedSpecies;
}
示例5: Percentage
//---------------------------------------------------------------------
static Percentage()
{
Util.Type.SetDescription<Percentage>("percentage");
InputValues.Register<Percentage>(Percentage.Parse);
MinValue = new Percentage(MinValueAsDouble);
MaxValue = new Percentage(MaxValueAsDouble);
}
示例6: AgeOrRangeWasRead
//---------------------------------------------------------------------
public void AgeOrRangeWasRead(AgeRange ageRange,
Percentage percentage)
{
Assert.AreEqual(expectedRange, ageRange);
if (expectedPercentage == null)
Assert.IsNull(percentage);
else
Assert.AreEqual((double) expectedPercentage, (double) percentage);
eventHandlerCalled = true;
}
示例7: ReduceInput
//---------------------------------------------------------------------
private static float ReduceInput(float poolInput,
Percentage reductionPercentage,
ActiveSite site)
{
float reduction = (poolInput * (float) reductionPercentage);
SiteVars.SourceSink[site].Carbon += (double) reduction * 0.47;
//SiteVars.FireEfflux[site] += (double) reduction * 0.47;
return (poolInput - reduction);
}
示例8: ReadAgeOrRange_RangePercentage
public void ReadAgeOrRange_RangePercentage()
{
StringReader reader = new StringReader("30-75(10%)");
int index;
eventHandlerCalled = false;
expectedRange = new AgeRange(30, 75);
expectedPercentage = Percentage.Parse("10%");
InputValue<AgeRange> ageRange = PartialThinning.ReadAgeOrRange(reader, out index);
Assert.IsTrue(eventHandlerCalled);
Assert.AreEqual(0, index);
Assert.AreEqual(-1, reader.Peek());
}
示例9: ReadAgeOrRange_AgeWhitespacePercentage
public void ReadAgeOrRange_AgeWhitespacePercentage()
{
StringReader reader = new StringReader("66 ( 50% )\t");
int index;
eventHandlerCalled = false;
expectedRange = new AgeRange(66, 66);
expectedPercentage = Percentage.Parse("50%");
InputValue<AgeRange> ageRange = PartialThinning.ReadAgeOrRange(reader, out index);
Assert.IsTrue(eventHandlerCalled);
Assert.AreEqual(0, index);
Assert.AreEqual('\t', reader.Peek());
}
示例10: ReadAgeOrRange_RangeWhitespacePercentage
public void ReadAgeOrRange_RangeWhitespacePercentage()
{
StringReader reader = new StringReader(" 1-100 (22.2%)Hi");
int index;
eventHandlerCalled = false;
expectedRange = new AgeRange(1, 100);
expectedPercentage = Percentage.Parse("22.2%");
InputValue<AgeRange> ageRange = PartialThinning.ReadAgeOrRange(reader, out index);
Assert.IsTrue(eventHandlerCalled);
Assert.AreEqual(1, index);
Assert.AreEqual('H', reader.Peek());
}
示例11: Selects
//---------------------------------------------------------------------
/// <summary>
/// Selects which cohorts are harvested.
/// </summary>
/// <returns>
/// true if the given cohort is to be harvested. The cohort's biomass
/// should be reduced by the percentage returned in the second
/// parameter.
/// </returns>
public bool Selects(ICohort cohort, out Percentage percentage)
{
ushort ageToLookUp = 0;
AgeRange? containingRange;
if (agesAndRanges.Contains(cohort.Age, out containingRange))
{
if (! containingRange.HasValue)
ageToLookUp = cohort.Age;
else {
ageToLookUp = containingRange.Value.Start;
}
if (! percentages.TryGetValue(ageToLookUp, out percentage))
percentage = defaultPercentage;
return true;
}
percentage = null;
return false;
}
示例12: AppliedPrescription
//---------------------------------------------------------------------
public AppliedPrescription(Prescription prescription,
Percentage percentageToHarvest,
int beginTime,
int endTime)
{
//set prescription
this.prescription = prescription;
//set stand ranking method
this.standSpreadSiteSelector = prescription.SiteSelectionMethod as StandSpreading;
//set harvest percentage
this.percentageToHarvest = percentageToHarvest;
//set begin time and end time
this.beginTime = beginTime;
this.endTime = endTime;
}
示例13: AppliedRepeatHarvest
//---------------------------------------------------------------------
public AppliedRepeatHarvest(RepeatHarvest repeatHarvest,
Percentage percentageToHarvest,
int beginTime,
int endTime)
: base(repeatHarvest,
percentageToHarvest,
beginTime,
endTime)
{
this.repeatHarvest = repeatHarvest;
if (repeatHarvest is SingleRepeatHarvest) {
isMultipleRepeatHarvest = false;
setAside = SetAsideForSingleHarvest;
}
else {
isMultipleRepeatHarvest = true;
setAside = SetAsideForMultipleHarvests;
}
this.reservedStands = new Queue<ReservedStand>();
}
示例14: ReadAgeOrRange_Multiple
public void ReadAgeOrRange_Multiple()
{
StringReader reader = new StringReader(" 1-40 (50%) 50(65%)\t 65-70 71-107 ( 15% ) 109");
int index; //0123456789_123456789_^123456789_123456789_12345678
eventHandlerCalled = false;
expectedRange = new AgeRange(1, 40);
expectedPercentage = Percentage.Parse("50%");
InputValue<AgeRange> ageRange = PartialThinning.ReadAgeOrRange(reader, out index);
Assert.IsTrue(eventHandlerCalled);
Assert.AreEqual(1, index);
Assert.AreEqual(' ', reader.Peek());
eventHandlerCalled = false;
expectedRange = new AgeRange(50, 50);
expectedPercentage = Percentage.Parse("65%");
ageRange = PartialThinning.ReadAgeOrRange(reader, out index);
Assert.IsTrue(eventHandlerCalled);
Assert.AreEqual(13, index);
Assert.AreEqual('\t', reader.Peek());
eventHandlerCalled = false;
expectedRange = new AgeRange(65, 70);
expectedPercentage = null;
ageRange = PartialThinning.ReadAgeOrRange(reader, out index);
Assert.IsTrue(eventHandlerCalled);
Assert.AreEqual(22, index);
Assert.AreEqual('7', reader.Peek());
eventHandlerCalled = false;
expectedRange = new AgeRange(71, 107);
expectedPercentage = Percentage.Parse("15%");
ageRange = PartialThinning.ReadAgeOrRange(reader, out index);
Assert.IsTrue(eventHandlerCalled);
Assert.AreEqual(29, index);
Assert.AreEqual(' ', reader.Peek());
eventHandlerCalled = false;
expectedRange = new AgeRange(109, 109);
expectedPercentage = null;
ageRange = PartialThinning.ReadAgeOrRange(reader, out index);
Assert.IsTrue(eventHandlerCalled);
Assert.AreEqual(45, index);
Assert.AreEqual(-1, reader.Peek());
}
示例15: ReduceInput
//---------------------------------------------------------------------
private static ushort ReduceInput(ushort poolInput,
Percentage reductionPercentage)
{
ushort reduction = (ushort) (poolInput * reductionPercentage);
return (ushort) (poolInput - reduction);
}