本文整理汇总了C#中DataValue类的典型用法代码示例。如果您正苦于以下问题:C# DataValue类的具体用法?C# DataValue怎么用?C# DataValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataValue类属于命名空间,在下文中一共展示了DataValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compute
public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
{
int numGood = 0;
int numBad = 0;
double total = 0.0;
foreach (DataValue v in bucket.Values)
{
if (state.RawValueIsGood(v))
{
numGood += 1;
total += Convert.ToDouble(v.Value, CultureInfo.InvariantCulture);
}
else
{
numBad += 1;
}
}
DataValue retval = new DataValue { SourceTimestamp = bucket.From };
StatusCode code = ComputeStatus(context, numGood, numBad, bucket).Code;
code.AggregateBits = AggregateBits.Calculated;
if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
if (StatusCode.IsNotBad(code))
retval.Value = total;
retval.StatusCode = code;
GoodDataCount = numGood;
return retval;
}
示例2: DataEntry
private DataValue val; //additional information like color
#endregion Fields
#region Constructors
public DataEntry(int id, double pca_x, double pca_y, DataValue val)
{
this.id = id;
this.pca_x = pca_x;
this.pca_y = pca_y;
this.val = val;
}
示例3: Compute
public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
{
int numGood = 0;
int numBad = 0;
DataValue previous = RightState(bucket.EarlyBound.Value) ? bucket.EarlyBound.Value : null;
double total = 0.0;
DataValue retval = new DataValue { SourceTimestamp = bucket.From };
StatusCode code = StatusCodes.BadNoData;
foreach (DataValue v in bucket.Values)
{
if (state.RawValueIsGood(v))
{
numGood += 1;
if (previous != null)
total += (v.SourceTimestamp - previous.SourceTimestamp).TotalMilliseconds;
previous = RightState(v) ? v : null;
}
else
{
numBad += 1;
}
}
if (previous != null)
total += (bucket.LateBound.Value.SourceTimestamp - previous.SourceTimestamp).TotalMilliseconds;
retval.Value = total;
code = ComputeStatus(context, numGood, numBad, bucket).Code;
code.AggregateBits = AggregateBits.Calculated;
if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
retval.StatusCode = code;
return retval;
}
示例4: DataValues
List<DataValue> _Items; // list of DataValue
public DataValues(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
{
DataValue dv;
_Items = new List<DataValue>();
// Loop thru all the child nodes
foreach(XmlNode xNodeLoop in xNode.ChildNodes)
{
if (xNodeLoop.NodeType != XmlNodeType.Element)
continue;
switch (xNodeLoop.Name)
{
case "DataValue":
dv = new DataValue(r, this, xNodeLoop);
break;
default:
dv=null; // don't know what this is
// don't know this element - log it
OwnerReport.rl.LogError(4, "Unknown DataValues element '" + xNodeLoop.Name + "' ignored.");
break;
}
if (dv != null)
_Items.Add(dv);
}
if (_Items.Count == 0)
OwnerReport.rl.LogError(8, "For DataValues at least one DataValue is required.");
else
_Items.TrimExcess();
}
示例5: getBasicRegionBlocks
private IEnumerable<Control> getBasicRegionBlocks()
{
var rs = new UpdateRegionSet();
var pb = PostBack.CreateIntermediate( rs.ToSingleElementArray(), DataUpdate, id: "basic" );
yield return new Paragraph( new PostBackButton( pb, new ButtonActionControlStyle( "Toggle Basic Region Below" ), usesSubmitBehavior: false ) );
var regionControls = new List<Control>();
var dynamicFieldValue = new DataValue<string>();
if( info.Toggled ) {
regionControls.Add(
FormItem.Create(
"Dynamic Field",
new EwfTextBox( "This was just added!" ),
validationGetter: control => new EwfValidation( ( pbv, validator ) => dynamicFieldValue.Value = control.GetPostBackValue( pbv ), pb ) ).ToControl() );
}
else
regionControls.Add( new Paragraph( "Nothing here yet." ) );
yield return
new NamingPlaceholder(
new Section( "Basic Update Region", regionControls, style: SectionStyle.Box ).ToSingleElementArray(),
updateRegionSets: rs.ToSingleElementArray() );
pb.AddModificationMethod( () => parametersModification.Toggled = !parametersModification.Toggled );
pb.AddModificationMethod(
() =>
AddStatusMessage( StatusMessageType.Info, info.Toggled ? "Dynamic field value was '{0}'.".FormatWith( dynamicFieldValue.Value ) : "Dynamic field added." ) );
}
示例6: Compute
public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
{
List<DataValue> l = new List<DataValue>(bucket.Values);
DataValue dv = l.Count > 0 ? GetDataValue(l) : null;
if (SteppedVariable && dv == null)
dv = bucket.LateBound.Value;
DataValue retval = new DataValue();
StatusCode code = StatusCodes.BadNoData;
if (dv != null)
{
code = StatusCode.IsNotGood(dv.StatusCode)
? StatusCodes.UncertainDataSubNormal
: StatusCodes.Good;
retval.SourceTimestamp = dv.SourceTimestamp;
retval.Value = dv.Value;
code.AggregateBits = AggregateBits.Raw;
if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
}
else
{
retval.SourceTimestamp = bucket.From;
}
retval.StatusCode = code;
return retval;
}
示例7: GetClrValue
/// <summary>
/// Gets the CLR value.
/// </summary>
/// <param name="val">The val.</param>
/// <returns></returns>
public static object GetClrValue(DataValue val)
{
if (val == null || val.IsNull())
return null;
switch (val.DataType)
{
case DataType.DataType_BLOB:
return ((BLOBValue)val).Data;
case DataType.DataType_Boolean:
return ((BooleanValue)val).Boolean;
case DataType.DataType_Byte:
return ((ByteValue)val).Byte;
case DataType.DataType_CLOB:
return ((CLOBValue)val).Data;
case DataType.DataType_DateTime:
return ((DateTimeValue)val).DateTime;
case DataType.DataType_Decimal:
return ((DecimalValue)val).Decimal;
case DataType.DataType_Double:
return ((DoubleValue)val).Double;
case DataType.DataType_Int16:
return ((Int16Value)val).Int16;
case DataType.DataType_Int32:
return ((Int32Value)val).Int32;
case DataType.DataType_Int64:
return ((Int64Value)val).Int64;
case DataType.DataType_Single:
return ((SingleValue)val).Single;
case DataType.DataType_String:
return ((StringValue)val).String;
default:
return null;
}
}
示例8: PropertyValueSnak
public PropertyValueSnak(PropertyId propertyId, DataValue value)
{
if (propertyId == null || value == null)
{
throw new ArgumentNullException("The property id and value must not be null");
}
PropertyId = propertyId;
Value = value;
}
示例9: Compute
public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
{
int numGood = 0;
int numBad = 0;
DataValue firstGoodDv = null;
DataValue lastGoodDv = null;
DataValue lastDv = null;
bool uncertainDataSubNormal = false;
double delta = double.NaN;
foreach (DataValue dv in bucket.Values)
{
if (state.RawValueIsGood(dv))
{
if (firstGoodDv == null)
{
firstGoodDv = dv;
}
lastGoodDv = dv;
numGood++;
}
else
{
// check for non-good value occuring before first good value
if (firstGoodDv == null)
uncertainDataSubNormal = true;
numBad++;
}
lastDv = dv;
}
if (firstGoodDv != null)
{
double fv = Convert.ToDouble(firstGoodDv.Value);
double lv = Convert.ToDouble(lastGoodDv.Value);
delta = lv - fv;
}
// check for non-good value occuring after latest good value
if (!uncertainDataSubNormal && lastGoodDv != null && lastGoodDv.SourceTimestamp < lastDv.SourceTimestamp)
uncertainDataSubNormal = true;
StatusCode code = (uncertainDataSubNormal)
? StatusCodes.UncertainDataSubNormal
: (numGood > 0) ? StatusCodes.Good : StatusCodes.BadNoData;
DataValue retval = new DataValue { SourceTimestamp = bucket.From };
if (!double.IsNaN(delta))
retval.Value = delta;
code.AggregateBits = AggregateBits.Calculated;
if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
retval.StatusCode = code;
return retval;
}
示例10: 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;
}
示例11: test1
private Box test1( DataModification dm, Action<string> setValue )
{
var box = new EwfTextBox( "" );
box.SetupAutoComplete( TestService.GetInfo(), AutoCompleteOption.NoPostBack );
var dv = new DataValue<string>();
dm.AddTopValidationMethod( ( pbvd, validator ) => dv.Value = box.GetPostBackValue( pbvd ) );
dm.AddModificationMethod( () => setValue( dv.Value ) );
return
new Box(
"Autofill behavior. Typing more than 3 characters should bring up autofill options from a web service. " +
"Selecting an item or changing the text will no cause a post-back. This value show appear when submitting the page's submit button.",
box.ToSingleElementArray() );
}
示例12: BuildLookupBoxPanel
/// <summary>
/// Builds this LookupBox and returns the panel.
/// </summary>
public WebControl BuildLookupBoxPanel()
{
var val = new DataValue<string>();
var postBack = PostBack.CreateFull( id: postBackId, actionGetter: () => new PostBackAction( handler( val.Value ) ) );
var textBox = FormItem.Create(
"",
new EwfTextBox( "", postBack: postBack ) { Width = new Unit( pixelWidth ) },
validationGetter: control => new EwfValidation( ( pbv, validator ) => val.Value = control.GetPostBackValue( pbv ), postBack ) );
textBox.Control.SetWatermarkText( defaultText );
if( autoCompleteService != null )
textBox.Control.SetupAutoComplete( autoCompleteService, AutoCompleteOption.PostBackOnItemSelect );
return new Block( textBox.ToControl() ) { CssClass = "ewfLookupBox" };
}
示例13: Compute
public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
{
DataValue retval = new DataValue { SourceTimestamp = bucket.From };
StatusCode code = StatusCodes.BadNoData;
DataValue boundValue = context.IsReverseAggregation ? bucket.LateBound.Value : bucket.EarlyBound.Value;
if (boundValue != null)
{
code = bucket.EarlyBound.Value.StatusCode.Code;
code.AggregateBits = bucket.EarlyBound.Value.StatusCode.AggregateBits;
retval.Value = Convert.ToDouble(bucket.EarlyBound.Value.Value, CultureInfo.InvariantCulture);
}
if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
retval.StatusCode = code;
return retval;
}
示例14: Compute
public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
{
int numGood = 0;
int numBad = 0;
double minV = double.MaxValue;
double maxV = double.MinValue;
bool uncertainDataSubNormal = false;
double range = double.NaN;
foreach (DataValue dv in bucket.Values)
{
if (state.RawValueIsGood(dv))
{
double v = Convert.ToDouble(dv.Value);
if (minV > v)
{
minV = v;
}
if (maxV < v)
{
maxV = v;
}
numGood++;
}
else
{
uncertainDataSubNormal = true;
numBad++;
}
}
if (minV != double.MaxValue && maxV != double.MinValue)
{
range = Math.Abs(maxV - minV);
}
StatusCode code = (uncertainDataSubNormal)
? StatusCodes.UncertainDataSubNormal
: StatusCodes.Good;
if (numGood + numBad == 0) code = StatusCodes.BadNoData;
DataValue retval = new DataValue { SourceTimestamp = bucket.From };
if (!double.IsNaN(range))
retval.Value = range;
code.AggregateBits = AggregateBits.Calculated;
if (bucket.Incomplete) code.AggregateBits |= AggregateBits.Partial;
retval.StatusCode = code;
return retval;
}
示例15: Compute
public override DataValue Compute(IAggregationContext context, TimeSlice bucket, AggregateState state)
{
StatusCode returnCode = StatusCodes.BadNoData;
foreach(DataValue dv in bucket.Values)
{
if (returnCode == StatusCodes.BadNoData)
{
returnCode = dv.StatusCode;
}
else
{
// StatusCodes.Bad = 0x80000000
// StatusCodes.Uncertain = 0x40000000
// StatusCodes.Good = 0x00000000
uint code = dv.StatusCode.Code >> 28; // 7 Hexadecimal digits = 28 binary digits.
switch (code)
{
case 8: // 8 is maximum
returnCode = StatusCodes.Bad;
break;
case 4:
if(StatusCode.IsNotBad(returnCode))
returnCode = StatusCodes.Uncertain;
break;
case 0: // 0 is minimum
break;
default:
Debug.Assert(true, "should not touch this line");
throw new Exception(String.Format("Unknown error in WorstQuality aggregate calculation, code = {0}", dv.StatusCode));
}
}
}
DataValue retVal = new DataValue() { SourceTimestamp = bucket.From };
if (returnCode != StatusCodes.BadNoData)
{
retVal.Value = returnCode;
StatusCode status = StatusCodes.Good;
status.AggregateBits |= AggregateBits.Calculated;
if (bucket.Incomplete) status.AggregateBits |= AggregateBits.Partial;
retVal.StatusCode = status;
}
else
{
retVal.StatusCode = returnCode;
}
return retVal;
}