当前位置: 首页>>代码示例>>C#>>正文


C# IScriptable.Get方法代码示例

本文整理汇总了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;
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:29,代码来源:ScriptableObject.cs

示例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 ();
            }
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:66,代码来源:ScriptRuntime.cs

示例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;
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:81,代码来源:ScriptRuntime.cs

示例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);
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:27,代码来源:ScriptRuntime.cs


注:本文中的IScriptable.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。