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


C# IScriptable.Has方法代码示例

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


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

示例1: GetBase

 private static IScriptable GetBase (IScriptable obj, string name)
 {
     do {
         if (obj.Has (name, obj))
             break;
         obj = obj.GetPrototype ();
     }
     while (obj != null);
     return obj;
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:10,代码来源:ScriptableObject.cs

示例2: ExecIdCall

        public override object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args)
        {
            if (!f.HasTag (OBJECT_TAG)) {
                return base.ExecIdCall (f, cx, scope, thisObj, args);
            }
            int id = f.MethodId;
            switch (id) {

                case Id_constructor: {
                        if (thisObj != null) {
                            // BaseFunction.construct will set up parent, proto
                            return f.Construct (cx, scope, args);
                        }
                        if (args.Length == 0 || args [0] == null || args [0] == Undefined.Value) {
                            return new BuiltinObject ();
                        }
                        return ScriptConvert.ToObject (cx, scope, args [0]);
                    }

                case Id_toLocaleString:
                // For now just alias toString
                case Id_toString: {
                        if (cx.HasFeature (Context.Features.ToStringAsSource)) {
                            string s = ScriptRuntime.defaultObjectToSource (cx, scope, thisObj, args);
                            int L = s.Length;
                            if (L != 0 && s [0] == '(' && s [L - 1] == ')') {
                                // Strip () that surrounds toSource
                                s = s.Substring (1, (L - 1) - (1));
                            }
                            return s;
                        }
                        return ScriptRuntime.DefaultObjectToString (thisObj);
                    }

                case Id_valueOf:
                    return thisObj;

                case Id_hasOwnProperty: {
                        bool result;
                        if (args.Length == 0) {
                            result = false;
                        }
                        else {
                            string s = ScriptRuntime.ToStringIdOrIndex (cx, args [0]);
                            if (s == null) {
                                int index = ScriptRuntime.lastIndexResult (cx);
                                result = thisObj.Has (index, thisObj);
                            }
                            else {
                                result = thisObj.Has (s, thisObj);
                            }
                        }
                        return result;
                    }

                case Id_propertyIsEnumerable: {
                        bool result;
                        if (args.Length == 0) {
                            result = false;
                        }
                        else {
                            string s = ScriptRuntime.ToStringIdOrIndex (cx, args [0]);
                            if (s == null) {
                                int index = ScriptRuntime.lastIndexResult (cx);
                                result = thisObj.Has (index, thisObj);
                                if (result && thisObj is ScriptableObject) {
                                    ScriptableObject so = (ScriptableObject)thisObj;
                                    int attrs = so.GetAttributes (index);
                                    result = ((attrs & ScriptableObject.DONTENUM) == 0);
                                }
                            }
                            else {
                                result = thisObj.Has (s, thisObj);
                                if (result && thisObj is ScriptableObject) {
                                    ScriptableObject so = (ScriptableObject)thisObj;
                                    int attrs = so.GetAttributes (s);
                                    result = ((attrs & ScriptableObject.DONTENUM) == 0);
                                }
                            }
                        }
                        return result;
                    }

                case Id_isPrototypeOf: {
                        bool result = false;
                        if (args.Length != 0 && args [0] is IScriptable) {
                            IScriptable v = (IScriptable)args [0];
                            do {
                                v = v.GetPrototype ();
                                if (v == thisObj) {
                                    result = true;
                                    break;
                                }
                            }
                            while (v != null);
                        }
                        return result;
                    }

                case Id_toSource:
//.........这里部分代码省略.........
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:101,代码来源:BuiltinObject.cs


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