本文整理汇总了C#中IValue.AsNumber方法的典型用法代码示例。如果您正苦于以下问题:C# IValue.AsNumber方法的具体用法?C# IValue.AsNumber怎么用?C# IValue.AsNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IValue
的用法示例。
在下文中一共展示了IValue.AsNumber方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetColumnByIIndex
public ValueTableColumn GetColumnByIIndex(IValue index)
{
if (index.DataType == DataType.String)
{
ValueTableColumn Column = FindColumnByName(index.AsString());
if (Column == null)
throw RuntimeException.PropNotFoundException(index.AsString());
return Column;
}
if (index.DataType == DataType.Number)
{
int i_index = Decimal.ToInt32(index.AsNumber());
if (i_index < 0 || i_index >= Count())
throw RuntimeException.InvalidArgumentValue();
ValueTableColumn Column = FindColumnByIndex(i_index);
return Column;
}
if (index is ValueTableColumn) {
return index as ValueTableColumn;
}
throw RuntimeException.InvalidArgumentType();
}
示例2: GetIndexedValue
public override IValue GetIndexedValue(IValue index)
{
var arrIdx = (int)index.AsNumber();
return ValueFactory.Create(_values[arrIdx]);
}
示例3: IsValueFilled
public bool IsValueFilled(IValue value)
{
if (value.DataType == DataType.Undefined)
return false;
else if (value.DataType == DataType.Boolean)
return true;
else if (value.DataType == DataType.String)
return !String.IsNullOrWhiteSpace(value.AsString());
else if (value.DataType == DataType.Number)
return value.AsNumber() != 0;
else if (value.DataType == DataType.Date)
{
var emptyDate = new DateTime(1, 1, 1, 0, 0, 0);
return value.AsDate() != emptyDate;
}
else if (value.GetRawValue() is ICollectionContext)
{
var col = value.GetRawValue() as ICollectionContext;
return col.Count() != 0;
}
else
return true;
}
示例4: Equals
public bool Equals(IValue other)
{
if (other.DataType == this.DataType)
{
switch (DataType)
{
case Machine.DataType.Number:
return this.AsNumber() == other.AsNumber();
case Machine.DataType.Boolean:
return this.AsBoolean() == other.AsBoolean();
case Machine.DataType.Date:
return this.AsDate() == other.AsDate();
case Machine.DataType.Undefined:
return true;
default:
return false;
}
}
else
{
return false;
}
}
示例5: CompareTo
public int CompareTo(IValue other)
{
if (other.DataType != this.DataType)
{
if (this.DataType == DataType.Boolean && other.DataType == DataType.Number
|| this.DataType == DataType.Number && other.DataType == DataType.Boolean)
{
return AsNumber().CompareTo(other.AsNumber());
}
else
{
throw RuntimeException.ComparisonNotSupportedException();
}
}
switch (other.DataType)
{
case Machine.DataType.Boolean:
return AsBoolean().CompareTo(other.AsBoolean());
case Machine.DataType.Date:
return AsDate().CompareTo(other.AsDate());
case Machine.DataType.Undefined:
return 0;
default:
return AsNumber().CompareTo(other.AsNumber());
}
}
示例6: Format
public static string Format(IValue value, string format)
{
var formatParameters = ParseParameters(format);
string formattedValue;
switch(value.DataType)
{
case DataType.Boolean:
formattedValue = FormatBoolean(value.AsBoolean(), formatParameters);
break;
case DataType.Number:
formattedValue = FormatNumber(value.AsNumber(), formatParameters);
break;
case DataType.Date:
formattedValue = FormatDate(value.AsDate(), formatParameters);
break;
default:
formattedValue = DefaultFormat(value, formatParameters);
break;
}
return formattedValue;
}