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


C# IScriptable.GetIds方法代码示例

本文整理汇总了C#中IScriptable.GetIds方法的典型用法代码示例。如果您正苦于以下问题:C# IScriptable.GetIds方法的具体用法?C# IScriptable.GetIds怎么用?C# IScriptable.GetIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScriptable的用法示例。


在下文中一共展示了IScriptable.GetIds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPropertyIds

 /// <summary> Returns an array of all ids from an object and its prototypes.
 /// <p>
 /// </summary>
 /// <param name="obj">a JavaScript object
 /// </param>
 /// <returns> an array of all ids from all object in the prototype chain.
 /// If a given id occurs multiple times in the prototype chain,
 /// it will occur only once in this list.
 /// </returns>
 public static object [] GetPropertyIds (IScriptable obj)
 {
     if (obj == null) {
         return ScriptRuntime.EmptyArgs;
     }
     object [] result = obj.GetIds ();
     ObjToIntMap map = null;
     for (; ; ) {
         obj = obj.GetPrototype ();
         if (obj == null) {
             break;
         }
         object [] ids = obj.GetIds ();
         if (ids.Length == 0) {
             continue;
         }
         if (map == null) {
             if (result.Length == 0) {
                 result = ids;
                 continue;
             }
             map = new ObjToIntMap (result.Length + ids.Length);
             for (int i = 0; i != result.Length; ++i) {
                 map.intern (result [i]);
             }
             result = null; // Allow to GC the result
         }
         for (int i = 0; i != ids.Length; ++i) {
             map.intern (ids [i]);
         }
     }
     if (map != null) {
         result = map.getKeys ();
     }
     return result;
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:45,代码来源: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


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