本文整理汇总了C#中JsValue.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# JsValue.GetType方法的具体用法?C# JsValue.GetType怎么用?C# JsValue.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsValue
的用法示例。
在下文中一共展示了JsValue.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Put
/// Implementation from ObjectInstance official specs as the one
/// in ObjectInstance is optimized for the general case and wouldn't work
/// for arrays
public override void Put(string propertyName, JsValue value, bool throwOnError)
{
if (!CanPut(propertyName))
{
if (throwOnError)
{
throw new JavaScriptException(Engine.TypeError);
}
return;
}
if (InternalArray != null)
{
int ind;
if (int.TryParse(propertyName, out ind))
{
object val;
switch (value.Type)
{
case Types.Undefined:
val = null;
break;
case Types.Null:
val = null;
break;
case Types.Boolean:
val = value.AsBoolean();
break;
case Types.String:
val = value.AsString();
break;
case Types.Number:
val = value.AsNumber();
break;
case Types.Object:
val = value;
var ow = ((JsValue)val).AsObject() as ObjectWrapper;
if (ow != null)
{
val = ow.Target;
}
break;
default:
throw new ArgumentOutOfRangeException();
}
if (ind >= InternalArray.Count)
{
for (int i = InternalArray.Count; i <= ind; i++)
{
if (val != null)
InternalArray.Add(GetDefault(val.GetType()));
else
InternalArray.Add(null);
}
}
InternalArray[ind] = val;
}
}
var ownDesc = GetOwnProperty(propertyName);
if (ownDesc.IsDataDescriptor())
{
var valueDesc = new PropertyDescriptor(value: value, writable: null, enumerable: null, configurable: null);
DefineOwnProperty(propertyName, valueDesc, throwOnError);
return;
}
// property is an accessor or inherited
var desc = GetProperty(propertyName);
if (desc.IsAccessorDescriptor())
{
var setter = desc.Set.Value.TryCast<ICallable>();
setter.Call(new JsValue(this), new[] { value });
}
else
{
var newDesc = new PropertyDescriptor(value, true, true, true);
DefineOwnProperty(propertyName, newDesc, throwOnError);
}
}