本文整理汇总了C#中Jint.Native.JsObject类的典型用法代码示例。如果您正苦于以下问题:C# JsObject类的具体用法?C# JsObject怎么用?C# JsObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsObject类属于Jint.Native命名空间,在下文中一共展示了JsObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Concat
/// <summary>
/// 15.4.4.4
/// </summary>
/// <param name="target"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public JsInstance Concat(JsObject target, JsInstance[] parameters)
{
if (target is JsArray)
return ((JsArray)target).concat(Global, parameters);
JsArray array = Global.ArrayClass.New();
List<JsInstance> items = new List<JsInstance>();
items.Add(target);
items.AddRange(parameters);
int n = 0;
while (items.Count > 0) {
JsInstance e = items[0];
items.RemoveAt(0);
if (Global.ArrayClass.HasInstance(e as JsObject)) {
for (int k = 0; k < ((JsObject)e).Length; k++) {
string p = k.ToString();
JsInstance result = null;
if (((JsObject)e).TryGetProperty(p, out result))
array.put(n, result);
n++;
}
}
else {
array.put(n, e);
n++;
}
}
return array;
}
开发者ID:cosh,项目名称:Jint,代码行数:34,代码来源:JsArrayConstructor.cs
示例2: DecodeURIComponent
public static object DecodeURIComponent(JintRuntime runtime, object @this, JsObject callee, object[] arguments)
{
if (arguments.Length < 1 || JsValue.IsUndefined(arguments[0]))
return String.Empty;
return Uri.UnescapeDataString(JsValue.ToString(arguments[0]).Replace("+", " "));
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:7,代码来源:JsGlobal.Scope.cs
示例3: Constructor
// 15.2.2.1
public static object Constructor(JintRuntime runtime, object @this, JsObject callee, object[] arguments)
{
// TODO: This looks wrong. It looks like this should be returning
// a JsObject that has the value set to the parameter. Chrome returns
// 'object' for typeof(new Object(7)) and typeof(Object(7)).
if (arguments.Length > 0)
{
var argument = arguments[0];
var global = runtime.Global;
switch (argument.GetJsType())
{
case JsType.String: return global.CreateObject(argument, global.StringClass);
case JsType.Number: return global.CreateObject((double)argument, global.NumberClass);
case JsType.Boolean: return global.CreateObject(argument, global.BooleanClass);
default: return argument;
}
}
var obj = runtime.Global.CreateObject(callee.Prototype);
obj.DefineProperty(
Id.constructor,
callee,
PropertyAttributes.DontEnum
);
return obj;
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:32,代码来源:JsGlobal.ObjectFunctions.cs
示例4: MarshalAccessorProperty
public MarshalAccessorProperty(int index, JsObject getter, JsObject setter, PropertyAttributes attributes)
{
Index = index;
Getter = getter;
Setter = setter;
Attributes = attributes;
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:7,代码来源:MarshalAccessorProperty.cs
示例5: ShouldHandleDictionaryObjects
public void ShouldHandleDictionaryObjects() {
var dic = new JsObject();
dic["prop1"] = new JsNumber(1, JsNull.Instance);
Assert.IsTrue(dic.HasProperty(new JsString("prop1", JsNull.Instance)));
Assert.IsTrue(dic.HasProperty("prop1"));
Assert.AreEqual(1, dic["prop1"].ToNumber());
}
开发者ID:arelee,项目名称:ravendb,代码行数:7,代码来源:Fixtures.cs
示例6: JsCallFunction
public JsCallFunction(JsFunctionConstructor constructor)
{
if (constructor != null)
Prototype = new JsObject() { Prototype = constructor.Prototype };
Prototype.DefineOwnProperty("length", new ValueDescriptor(Prototype, "length", constructor.Global.NumberClass.New(1)) { Writable = false });
}
开发者ID:pusp,项目名称:o2platform,代码行数:7,代码来源:JsCallFunction.cs
示例7: JsFunction
/// <summary>
/// Init new function object with a specified prototype
/// </summary>
/// <param name="prototype">prototype for this object</param>
public JsFunction(JsObject prototype)
: base(prototype)
{
Arguments = new List<string>();
Statement = new EmptyStatement();
DefineOwnProperty(PROTOTYPE, JsNull.Instance, PropertyAttributes.DontEnum);
}
开发者ID:splhack,项目名称:unity-jint,代码行数:11,代码来源:JsFunction.cs
示例8: InitPrototype
public override void InitPrototype(IGlobal global)
{
Prototype = new JsObject() { Prototype = global.FunctionClass.Prototype };
Prototype.DefineOwnProperty("constructor", this, PropertyAttributes.DontEnum);
#region Methods
Prototype.DefineOwnProperty("toString", global.FunctionClass.New<JsArray>(ToStringImpl), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("toLocaleString", global.FunctionClass.New<JsArray>(ToLocaleStringImpl), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("concat", global.FunctionClass.New<JsObject>(Concat), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("join", global.FunctionClass.New<JsObject>(Join, 1), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("pop", global.FunctionClass.New<JsObject>(Pop), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("push", global.FunctionClass.New<JsObject>(Push, 1), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("reverse", global.FunctionClass.New<JsObject>(Reverse), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("shift", global.FunctionClass.New<JsObject>(Shift), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("slice", global.FunctionClass.New<JsObject>(Slice, 2), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("sort", global.FunctionClass.New<JsObject>(Sort), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("splice", global.FunctionClass.New<JsObject>(Splice, 2), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("unshift", global.FunctionClass.New<JsObject>(UnShift, 1), PropertyAttributes.DontEnum);
#region ES5
Prototype.DefineOwnProperty("indexOf", global.FunctionClass.New<JsObject>(IndexOfImpl, 1), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("lastIndexOf", global.FunctionClass.New<JsObject>(LastIndexOfImpl, 1), PropertyAttributes.DontEnum);
#endregion
#endregion
}
开发者ID:Fedorm,项目名称:core-master,代码行数:26,代码来源:JsArrayConstructor.cs
示例9: Constructor
public static object Constructor(JintRuntime runtime, object @this, JsObject callee, object[] arguments)
{
var target = (JsObject)@this;
if (target == runtime.Global.GlobalScope)
target = runtime.Global.CreateObject(callee.Prototype);
string pattern = null;
string options = null;
if (arguments.Length > 0)
{
pattern = JsValue.ToString(arguments[0]);
if (arguments.Length > 1)
options = JsValue.ToString(arguments[1]);
}
var manager = new RegexManager(pattern, options);
target.SetClass(JsNames.ClassRegexp);
target.IsClr = false;
target.Value = manager;
target.SetProperty(Id.source, pattern);
target.SetProperty(Id.lastIndex, (double)0);
target.SetProperty(Id.global, BooleanBoxes.Box(manager.IsGlobal));
return target;
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:28,代码来源:JsGlobal.RegExpFunctions.cs
示例10: Exec
public static object Exec(JintRuntime runtime, object @this, JsObject callee, object[] arguments)
{
var target = (JsObject)@this;
var manager = (RegexManager)target.Value;
return (object)manager.Exec(runtime, JsValue.ToString(arguments[0])) ?? JsNull.Instance;
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:7,代码来源:JsGlobal.RegExpFunctions.cs
示例11: CreateError
public JsObject CreateError(JsObject constructor, string message)
{
return constructor.Construct(
_runtime,
new[] { (object)message }
);
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:7,代码来源:JsGlobal.Builders.cs
示例12: Call
public static object Call(JintRuntime runtime, object @this, JsObject callee, object[] arguments)
{
if (!JsValue.IsFunction(@this))
throw new JsException(JsErrorType.TypeError, "The target of call() must be a function");
object target;
if (arguments.Length >= 1 && !JsValue.IsNullOrUndefined(arguments[0]))
target = arguments[0];
else
target = runtime.GlobalScope;
object[] argumentsCopy;
if (arguments.Length >= 2 && !JsValue.IsNull(arguments[1]))
{
argumentsCopy = new object[arguments.Length - 1];
Array.Copy(arguments, 1, argumentsCopy, 0, argumentsCopy.Length);
}
else
{
argumentsCopy = JsValue.EmptyArray;
}
// Executes the statements in 'that' and use _this as the target of the call
return ((JsObject)@this).Execute(runtime, target, argumentsCopy);
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:26,代码来源:JsGlobal.FunctionFunctions.cs
示例13: Apply
public static object Apply(JintRuntime runtime, object @this, JsObject callee, object[] arguments)
{
if (!JsValue.IsFunction(@this))
throw new ArgumentException("The target of call() must be a function");
object target;
if (arguments.Length >= 1 && !JsValue.IsNullOrUndefined(arguments[0]))
target = arguments[0];
else
target = runtime.Global.GlobalScope;
object[] argumentsCopy;
if (arguments.Length >= 2)
{
var shim = new ArrayShim(arguments[1]);
argumentsCopy = new object[shim.Length];
foreach (var item in shim)
{
argumentsCopy[item.Key] = item.Value;
}
}
else
{
argumentsCopy = JsValue.EmptyArray;
}
// Executes the statements in 'that' and use _this as the target of the call
return ((JsObject)@this).Execute(runtime, target, argumentsCopy);
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:33,代码来源:JsGlobal.FunctionFunctions.cs
示例14: NativeMethodOverload
public NativeMethodOverload(ICollection<MethodInfo> methods , JsObject prototype, IGlobal global)
: base(prototype)
{
if (global == null)
throw new ArgumentNullException("global");
m_marshaller = global.Marshaller;
foreach (MethodInfo info in methods)
{
Name = info.Name;
break;
}
foreach (var method in methods)
{
if (method.IsGenericMethodDefinition)
m_generics.AddLast(method);
else if (! method.ContainsGenericParameters)
m_methods.AddLast(method);
}
m_overloads = new NativeOverloadImpl<MethodInfo, JsMethodImpl>(
m_marshaller,
new NativeOverloadImpl<MethodInfo, JsMethodImpl>.GetMembersDelegate(this.GetMembers),
new NativeOverloadImpl<MethodInfo, JsMethodImpl>.WrapMmemberDelegate(this.WrapMember)
);
}
开发者ID:cosh,项目名称:Jint,代码行数:27,代码来源:NativeMethodOverload.cs
示例15: PropertyAccessor
public PropertyAccessor(JsObject getter, JsObject setter)
{
if (getter == null)
throw new ArgumentNullException("getter");
Getter = getter;
Setter = setter;
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:8,代码来源:PropertyAccessor.cs
示例16: DictionaryPropertyStore
public DictionaryPropertyStore(JsObject owner)
{
if (owner == null)
throw new ArgumentNullException("owner");
Owner = owner;
_global = Owner.Global;
Schema = _global.RootSchema;
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:9,代码来源:DictionaryPropertyStore.cs
示例17: InitPrototype
public override void InitPrototype(IGlobal global)
{
Prototype = new JsObject() { Prototype = global.FunctionClass.Prototype };
Prototype.DefineOwnProperty("constructor", this, PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("toString", global.FunctionClass.New<JsDictionaryObject>(ToString2), PropertyAttributes.DontEnum);
Prototype.DefineOwnProperty("toLocaleString", global.FunctionClass.New<JsDictionaryObject>(ToString2), PropertyAttributes.DontEnum);
}
开发者ID:pusp,项目名称:o2platform,代码行数:9,代码来源:JsBooleanConstructor.cs
示例18: DefineAccessor
public void DefineAccessor(int index, JsObject getter, JsObject setter, PropertyAttributes attributes)
{
EnsurePropertyStore();
PropertyStore.DefineProperty(
index,
new PropertyAccessor(getter, setter),
attributes
);
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:9,代码来源:JsObject.Properties.cs
示例19: DefineProperty
public void DefineProperty(JsObject @object)
{
@object.DefineAccessor(
Index,
Getter,
Setter,
Attributes
);
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:9,代码来源:MarshalAccessorProperty.cs
示例20: GetPrototypeOf
// 15.2.3.2
public static object GetPrototypeOf(JintRuntime runtime, object @this, JsObject callee, object[] arguments)
{
var @object = arguments[0] as JsObject;
if (@object == null)
throw new JsException(JsErrorType.TypeError);
var constructor = @object.GetProperty(Id.constructor) as JsObject;
if (constructor != null)
return constructor.GetProperty(Id.prototype);
return JsNull.Instance;
}
开发者ID:pvginkel,项目名称:Jint2,代码行数:13,代码来源:JsGlobal.ObjectFunctions.cs
注:本文中的Jint.Native.JsObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论