本文整理汇总了C#中DataValue.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# DataValue.Clone方法的具体用法?C# DataValue.Clone怎么用?C# DataValue.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataValue
的用法示例。
在下文中一共展示了DataValue.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Comparison
protected abstract bool Comparison(DataValue value1, DataValue value2); // true if keep value1.
public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
{
int numGood = 0;
int numBad = 0;
DataValue valueToKeep = new DataValue() { SourceTimestamp = bucket.From, StatusCode = StatusCodes.BadNoData };
bool moreData = false;
bool hasGoodData = false;
foreach (DataValue dv in bucket.Values)
{
if (state.RawValueIsGood(dv))
{
hasGoodData = true;
if (valueToKeep.StatusCode == StatusCodes.BadNoData)
{
valueToKeep = dv;
}
else
{
moreData = valueToKeep == dv;
if (Comparison(dv, valueToKeep))
{
valueToKeep = dv;
}
}
numGood++;
}
else
{
numBad++;
if (!hasGoodData)
valueToKeep = dv;
}
}
DataValue retval = valueToKeep.StatusCode == StatusCodes.BadNoData ? valueToKeep : (DataValue)valueToKeep.Clone();
if (hasGoodData)
{
StatusCode code = StatusCodes.Good;
code = ComputeStatus(context, numGood, numBad, bucket).Code;
code.AggregateBits = moreData ? AggregateBits.ExtraData : AggregateBits.Raw;
if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
retval.StatusCode = code;
} // numGood = 0, hasGoodData = false beyond this point, i.e., no good data
else if(numBad > 0)
{
retval.Value = null;
retval.StatusCode = StatusCodes.Bad;
retval.StatusCode = retval.StatusCode.SetAggregateBits(AggregateBits.Raw);
}
return retval;
}