本文整理汇总了C#中IScriptable.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IScriptable.Get方法的具体用法?C# IScriptable.Get怎么用?C# IScriptable.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScriptable
的用法示例。
在下文中一共展示了IScriptable.Get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperty
/// <summary> Gets an indexed property from an object or any object in its prototype chain.
/// <p>
/// Searches the prototype chain for a property with integral index
/// <code>index</code>. Note that if you wish to look for properties with numerical
/// but non-integral indicies, you should use getProperty(Scriptable,String) with
/// the string value of the index.
/// <p>
/// </summary>
/// <param name="obj">a JavaScript object
/// </param>
/// <param name="index">an integral index
/// </param>
/// <returns> the value of a property with index <code>index</code> found in
/// <code>obj</code> or any object in its prototype chain, or
/// <code>Scriptable.NOT_FOUND</code> if not found
/// </returns>
public static object GetProperty (IScriptable obj, int index)
{
IScriptable start = obj;
object result;
do {
result = obj.Get (index, start);
if (result != UniqueTag.NotFound)
break;
obj = obj.GetPrototype ();
}
while (obj != null);
return result;
}
示例2: defaultObjectToSource
internal static string defaultObjectToSource(Context cx, IScriptable scope, IScriptable thisObj, object [] args)
{
using (Helpers.StackOverflowVerifier sov = new Helpers.StackOverflowVerifier (1024)) {
bool toplevel, iterating;
if (cx.iterating == null) {
toplevel = true;
iterating = false;
cx.iterating = new ObjToIntMap (31);
}
else {
toplevel = false;
iterating = cx.iterating.has (thisObj);
}
System.Text.StringBuilder result = new System.Text.StringBuilder (128);
if (toplevel) {
result.Append ("(");
}
result.Append ('{');
// Make sure cx.iterating is set to null when done
// so we don't leak memory
try {
if (!iterating) {
cx.iterating.intern (thisObj); // stop recursion.
object [] ids = thisObj.GetIds ();
for (int i = 0; i < ids.Length; i++) {
if (i > 0)
result.Append (", ");
object id = ids [i];
object value;
if (id is int) {
int intId = ((int)id);
value = thisObj.Get (intId, thisObj);
result.Append (intId);
}
else {
string strId = (string)id;
value = thisObj.Get (strId, thisObj);
if (ScriptRuntime.isValidIdentifierName (strId)) {
result.Append (strId);
}
else {
result.Append ('\'');
result.Append (ScriptRuntime.escapeString (strId, '\''));
result.Append ('\'');
}
}
result.Append (':');
result.Append (ScriptRuntime.uneval (cx, scope, value));
}
}
}
finally {
if (toplevel) {
cx.iterating = null;
}
}
result.Append ('}');
if (toplevel) {
result.Append (')');
}
return result.ToString ();
}
}
示例3: nameOrFunction
private static object nameOrFunction(Context cx, IScriptable scope, IScriptable parentScope, string name, bool asFunctionCall)
{
object result;
IScriptable thisObj = scope; // It is used only if asFunctionCall==true.
XMLObject firstXMLObject = null;
for (; ; ) {
if (scope is BuiltinWith) {
IScriptable withObj = scope.GetPrototype ();
if (withObj is XMLObject) {
XMLObject xmlObj = (XMLObject)withObj;
if (xmlObj.EcmaHas (cx, name)) {
// function this should be the target object of with
thisObj = xmlObj;
result = xmlObj.EcmaGet (cx, name);
break;
}
if (firstXMLObject == null) {
firstXMLObject = xmlObj;
}
}
else {
result = ScriptableObject.GetProperty (withObj, name);
if (result != UniqueTag.NotFound) {
// function this should be the target object of with
thisObj = withObj;
break;
}
}
}
else if (scope is BuiltinCall) {
// NativeCall does not prototype chain and Scriptable.get
// can be called directly.
result = scope.Get (name, scope);
if (result != UniqueTag.NotFound) {
if (asFunctionCall) {
// ECMA 262 requires that this for nested funtions
// should be top scope
thisObj = ScriptableObject.GetTopLevelScope (parentScope);
}
break;
}
}
else {
// Can happen if embedding decided that nested
// scopes are useful for what ever reasons.
result = ScriptableObject.GetProperty (scope, name);
if (result != UniqueTag.NotFound) {
thisObj = scope;
break;
}
}
scope = parentScope;
parentScope = parentScope.ParentScope;
if (parentScope == null) {
result = topScopeName (cx, scope, name);
if (result == UniqueTag.NotFound) {
if (firstXMLObject == null || asFunctionCall) {
throw NotFoundError (scope, name);
}
// The name was not found, but we did find an XML
// object in the scope chain and we are looking for name,
// not function. The result should be an empty XMLList
// in name context.
result = firstXMLObject.EcmaGet (cx, name);
}
// For top scope thisObj for functions is always scope itself.
thisObj = scope;
break;
}
}
if (asFunctionCall) {
if (!(result is ICallable)) {
throw NotFunctionError (result, name);
}
storeScriptable (cx, thisObj);
}
return result;
}
示例4: nameIncrDecr
public static object nameIncrDecr(IScriptable scopeChain, string id, int incrDecrMask)
{
IScriptable target;
object value;
{
do {
target = scopeChain;
do {
value = target.Get (id, scopeChain);
if (value != UniqueTag.NotFound) {
goto search_brk;
}
target = target.GetPrototype ();
}
while (target != null);
scopeChain = scopeChain.ParentScope;
}
while (scopeChain != null);
throw NotFoundError (scopeChain, id);
}
search_brk:
;
return doScriptableIncrDecr (target, id, scopeChain, value, incrDecrMask);
}