本文整理汇总了C#中Jint.Native.JsInstance.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# JsInstance.ToString方法的具体用法?C# JsInstance.ToString怎么用?C# JsInstance.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jint.Native.JsInstance
的用法示例。
在下文中一共展示了JsInstance.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsException
public JsException(JsInstance value)
: base(value.ToString())
{
Value = value;
//if (value is JsDictionaryObject)
// ((JsDictionaryObject)value)["jintException"] = new JsClr(this);
}
示例2:
/// <summary>
/// Overriden indexer to optimize cases when we already have a number
/// </summary>
/// <param name="key">index</param>
/// <returns>value</returns>
public override JsInstance this[JsInstance key] {
get {
double keyNumber = key.ToNumber();
int i = (int)keyNumber;
if (i == keyNumber && i >= 0) {
// we have got an index
return this.get(i);
}
else {
return base[key.ToString()];
}
}
set {
double keyNumber = key.ToNumber();
int i = (int)keyNumber;
if (i == keyNumber && i >= 0) {
// we have got an index
this.put(i, value);
}
else {
base[key.ToString()] = value;
}
}
}
示例3: GiveMeJavascript
private static JsString GiveMeJavascript(JsNumber number, JsInstance instance) {
return new JsString(number + instance.ToString(), JsNull.Instance);
}
示例4: join
public JsString join(IGlobal global, JsInstance separator)
{
if (length == 0)
return global.StringClass.New();
string sep = separator == JsUndefined.Instance ? "," : separator.ToString();
string[] map = new string[length];
JsInstance item;
for (int i = 0; i < length; i++)
map[i] = m_data.TryGetValue(i, out item) && item != JsNull.Instance && item != JsUndefined.Instance ? item.ToString() : "";
return global.StringClass.New(String.Join(sep, map));
}
示例5: Delete
public override void Delete(JsInstance key)
{
double keyNumber = key.ToNumber();
int index = (int)keyNumber;
if (index == keyNumber)
m_data.Remove(index);
else
base.Delete(key.ToString());
}
示例6: ToFixedImpl
/// <summary>
/// 15.7.4.5
/// </summary>
/// <param name="target"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public JsInstance ToFixedImpl(JsInstance target, JsInstance[] parameters)
{
int fractions = 0;
if (parameters.Length > 0) {
fractions = Convert.ToInt32(parameters[0].ToNumber());
}
if (fractions > 20 || fractions < 0) {
throw new JsException(Global.SyntaxErrorClass.New("Fraction Digits must be greater than 0 and lesser than 20"));
}
if (target == Global.NaN) {
return Global.StringClass.New(target.ToString());
}
return Global.StringClass.New(target.ToNumber().ToString("f" + fractions, CultureInfo.InvariantCulture));
}
示例7: Compare
public JsBoolean Compare(JsInstance x, JsInstance y)
{
if (x.IsClr && y.IsClr)
{
return Global.BooleanClass.New(x.Value.Equals(y.Value));
}
if (x.IsClr)
{
return Compare(x.ToPrimitive(Global), y);
}
if (y.IsClr)
{
return Compare(x, y.ToPrimitive(Global));
}
if (x.Type == y.Type)
{ // if both are Objects but then only one is Clrs
if (x == JsUndefined.Instance)
{
return Global.BooleanClass.True;
}
else if (x == JsNull.Instance)
{
return Global.BooleanClass.True;
}
else if (x.Type == JsInstance.TYPE_NUMBER)
{
if (x.ToNumber() == double.NaN)
{
return Global.BooleanClass.False;
}
else if (y.ToNumber() == double.NaN)
{
return Global.BooleanClass.False;
}
else if (x.ToNumber() == y.ToNumber())
{
return Global.BooleanClass.True;
}
else
{
return Global.BooleanClass.False;
}
}
else if (x.Type == JsInstance.TYPE_STRING)
{
return Global.BooleanClass.New(x.ToString() == y.ToString());
}
else if (x.Type == JsInstance.TYPE_BOOLEAN)
{
return Global.BooleanClass.New(x.ToBoolean() == y.ToBoolean());
}
else if (x.Type == JsInstance.TYPE_OBJECT )
{
return Global.BooleanClass.New(x == y);
}
else
{
return Global.BooleanClass.New(x.Value.Equals(y.Value));
}
}
else if (x == JsNull.Instance && y == JsUndefined.Instance)
{
return Global.BooleanClass.True;
}
else if (x == JsUndefined.Instance && y == JsNull.Instance)
{
return Global.BooleanClass.True;
}
else if (x.Type == JsInstance.TYPE_NUMBER && y.Type == JsInstance.TYPE_STRING)
{
return Global.BooleanClass.New(x.ToNumber() == y.ToNumber());
}
else if (x.Type == JsInstance.TYPE_STRING && y.Type == JsInstance.TYPE_NUMBER)
{
return Global.BooleanClass.New(x.ToNumber() == y.ToNumber());
}
else if (x.Type == JsInstance.TYPE_BOOLEAN || y.Type == JsInstance.TYPE_BOOLEAN)
{
return Global.BooleanClass.New(x.ToNumber() == y.ToNumber());
}
else if (y.Type == JsInstance.TYPE_OBJECT && (x.Type == JsInstance.TYPE_STRING || x.Type == JsInstance.TYPE_NUMBER))
{
return Compare(x, y.ToPrimitive(Global));
}
else if (x.Type == JsInstance.TYPE_OBJECT && (y.Type == JsInstance.TYPE_STRING || y.Type == JsInstance.TYPE_NUMBER))
{
return Compare(x.ToPrimitive(Global), y);
}
else
{
return Global.BooleanClass.False;
}
}