本文整理汇总了C#中PValue.ConvertTo方法的典型用法代码示例。如果您正苦于以下问题:C# PValue.ConvertTo方法的具体用法?C# PValue.ConvertTo怎么用?C# PValue.ConvertTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PValue
的用法示例。
在下文中一共展示了PValue.ConvertTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunStatically
public static PValue RunStatically(PValue arg0, StackContext sctx)
{
var x = (double) arg0.ConvertTo(sctx, PType.Real, true).Value;
return System.Math.Tan(x);
}
示例2: RunStatically
public static PValue RunStatically(PValue arg, StackContext sctx)
{
if (sctx == null)
throw new ArgumentNullException("sctx");
if (arg == null)
throw new ArgumentNullException("arg");
if (arg.Type == PType.Int)
{
var x = (int) arg.Value;
return System.Math.Abs(x);
}
else
{
var x = (double) arg.ConvertTo(sctx, PType.Real, true).Value;
return System.Math.Abs(x);
}
}
示例3: _getMacroRef
private static EntityRef _getMacroRef(StackContext sctx, PValue rawMacro)
{
PFunction func;
MacroCommand mcmd;
if (rawMacro.TryConvertTo(sctx, out func))
return EntityRef.Function.Create(func.Id, func.ParentApplication.Module.Name);
else if (rawMacro.TryConvertTo(sctx, out mcmd))
return EntityRef.MacroCommand.Create(mcmd.Id);
else
return rawMacro.ConvertTo<EntityRef>(sctx);
}
示例4: RunStatically
public static PValue RunStatically(PValue arg0, PValue arg1, StackContext sctx)
{
if (arg0.Type == PType.Int && arg1.Type == PType.Int)
{
var a = (int) arg0.Value;
var b = (int) arg1.Value;
return System.Math.Max(a, b);
}
else
{
var a = (double) arg0.ConvertTo(sctx, PType.Real, true).Value;
var b = (double) arg1.ConvertTo(sctx, PType.Real, true).Value;
return System.Math.Max(a, b);
}
}
示例5: RunStatically
public static PValue RunStatically(PValue arg0, PValue arg1, StackContext sctx)
{
var x = (double) arg0.ConvertTo(sctx, PType.Real, true).Value;
int d;
PValue pd;
if (arg1 != null && arg1.TryConvertTo(sctx, PType.Int, true, out pd))
d = System.Math.Abs((int) pd.Value);
else
d = 0;
return System.Math.Round(x, d, MidpointRounding.AwayFromZero);
}