本文整理汇总了C#中IConvertible类的典型用法代码示例。如果您正苦于以下问题:C# IConvertible类的具体用法?C# IConvertible怎么用?C# IConvertible使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IConvertible类属于命名空间,在下文中一共展示了IConvertible类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetOperand
private void SetOperand(IConvertible operand)
{
switch (Instruction)
{
case BFInstruction.SetVariable:
case BFInstruction.PushVariable:
case BFInstruction.PushUInt16:
case BFInstruction.JumpIfFalse:
case BFInstruction.Jump:
case BFInstruction.CallProcedure:
case BFInstruction.CallNative:
case BFInstruction.BeginProcedure:
case BFInstruction.PushUInt32:
if (operand == null)
throw new ArgumentException("You must specify 1 operand for this instruction.");
_operand = new BFOperand(Convert.ToInt64(operand));
break;
case BFInstruction.PushFloat:
if (operand == null)
throw new ArgumentException("You must specify 1 operand for this instruction.");
_operand = new BFOperand(Convert.ToSingle(operand));
break;
default:
if (operand != null)
_operand = new BFOperand(Convert.ToInt64(operand));
break;
}
}
示例2: DoBinOp
protected override IConvertible DoBinOp(IConvertible left, IConvertible right)
{
Boolean left1 = Convert.ToBoolean(left);
Boolean right1 = Convert.ToBoolean(right);
return left1 && right1;
}
示例3: SpriteKernel
protected SpriteKernel(IConvertible initialVersion)
{
SourceList = new Dictionary<IConvertible, SpriteSource>();
Animation = new PeriodicFunction<SpriteTransformation>(stage => new SpriteTransformation(0));
RegisteredVersion = new Collection<IConvertible>();
Version = initialVersion;
}
示例4: GetValue
protected override IConvertible GetValue()
{
// if (!isGotValue)
// {
if (OnGetValue == null)
{
throw new InvalidOperationException("This variable is not bound to a formula, so it's value cannot be read.");
}
VariableReadEventArgs args = new VariableReadEventArgs(Name);
args.Type = Type;
OnGetValue(this, args);
if (Type != typeof(IConvertible))
{
_Value = (IConvertible)Convert.ChangeType(args.Value, Type);
}
else
{
_Value = args.Value;
}
// isGotValue = true;
// }
return _Value;
}
示例5: ValueCell
public ValueCell(StructField def, IConvertible value, string displayValue, int offset)
: base(def)
{
_value = value;
_displayValue = displayValue;
_offset = offset;
}
示例6: AddNumber
public override string AddNumber(IConvertible number, IList<DbParameter> parameters)
{
if (number == null)
{
throw new ArgumentNullException("number");
}
return number.ToString();
}
示例7: ProxyNumber
public ProxyNumber( IConvertible value )
{
if (value is string)
{
this.value = Parse( value as string );
}
else
{
this.value = value;
}
}
示例8: DoBinOp
protected override IConvertible DoBinOp(IConvertible left, IConvertible right)
{
IComparable left1 = (IComparable)left;
IComparable right1 = (IComparable)right;
if (left1.CompareTo(right1) > 0)
{
return true;
}
return false;
}
示例9: Ignore
public Tokenizer Ignore(int priority, IConvertible tokenName, String tokenRegex)
{
try {
Regex.Replace("", tokenRegex, "");
tokenPriorities[tokenName] = priority;
tokens[tokenName] = new Regex("^" + tokenRegex + "$");
ignore[tokenName] = true;
} catch (Exception e) {
throw (e);
}
return (this);
}
示例10: AddDecimal
private static object AddDecimal(IConvertible Left, IConvertible Right)
{
decimal num = Left.ToDecimal(null);
decimal num2 = Right.ToDecimal(null);
try
{
return decimal.Add(num, num2);
}
catch (OverflowException)
{
return (Convert.ToDouble(num) + Convert.ToDouble(num2));
}
}
示例11: Prop
/// <summary>
/// Set one or more properties for the set of matched elements.
/// </summary>
///
/// <param name="name">
/// The property to set
/// </param>
/// <param name="value">
/// The value
/// </param>
///
/// <returns>
/// The current CQ object
/// </returns>
public CQ Prop(string name, IConvertible value)
{
// Prop actually works on things other than boolean - e.g. SelectedIndex. For now though only use prop for booleans
if (HtmlData.IsBoolean(name))
{
SetProp(name, value);
}
else
{
Attr(name, value);
}
return this;
}
示例12: DateTimeFormatPartOptionTO
public DateTimeFormatPartOptionTO(int length, Func<string, bool, bool> predicate, bool isNumeric,
IConvertible actualValue, Action<IDateTimeResultTO, bool, IConvertible> assignAction, int resultLength = -1)
{
Length = length;
Predicate = predicate;
IsNumeric = isNumeric;
ActualValue = actualValue;
AssignAction = assignAction;
if (resultLength == -1)
{
ResultLength = Length;
}
else
{
ResultLength = resultLength;
}
}
示例13: AddDecimal
private static object AddDecimal(IConvertible conv1, IConvertible conv2)
{
decimal num;
if (conv1 != null)
{
num = conv1.ToDecimal(null);
}
decimal num2 = conv2.ToDecimal(null);
try
{
return decimal.Add(num, num2);
}
catch (OverflowException)
{
return (Convert.ToDouble(num) + Convert.ToDouble(num2));
}
}
示例14: Eval
public override object Eval (DataRow row)
{
//TODO: implement a better caching strategy and a mechanism for cache invalidation.
//for now only aggregation over the table owning 'row' (e.g. 'sum(parts)'
//in constrast to 'sum(parent.parts)' and 'sum(child.parts)') is cached.
if (cacheResults && result != null && column.ReferencedTable == ReferencedTable.Self)
return result;
count = 0;
result = null;
object[] values;
if (rows == null)
values = column.GetValues (column.GetReferencedRows (row));
else
values = column.GetValues (rows);
foreach (object val in values) {
if (val == null)
continue;
count++;
Aggregate ((IConvertible)val);
}
switch (function) {
case AggregationFunction.StDev:
case AggregationFunction.Var:
result = CalcStatisticalFunction (values);
break;
case AggregationFunction.Avg:
result = Numeric.Divide (result, count);
break;
case AggregationFunction.Count:
result = count;
break;
}
if (result == null)
result = DBNull.Value;
return result;
}
示例15: SetProperty
public void SetProperty(string property, IConvertible prop_val)
{
PropertyInfo prop_info = item.GetType ().GetProperty (property);
if (prop_info == null)
throw new ApplicationException (String.Format (
"Unable to set property {0}.{1} to \"{2}\"",
item.GetType (), property, prop_val));
Type prop_type = prop_info.PropertyType;
object param;
try {
param = prop_val.ToType (prop_type, NumberFormatInfo.InvariantInfo);
} catch (FormatException e) {
throw new ApplicationException (String.Format (
"prop_val cannot be converted to a {0}", prop_type), e);
}
prop_info.SetValue (item, param, null);
}