• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IScriptable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: BuiltinCall

        internal BuiltinCall(BuiltinFunction function, IScriptable scope, object [] args)
        {
            this.function = function;

            ParentScope = scope;
            // leave prototype null

            this.originalArgs = (args == null) ? ScriptRuntime.EmptyArgs : args;

            // initialize values of arguments
            int paramAndVarCount = function.ParamAndVarCount;
            int paramCount = function.ParamCount;
            if (paramAndVarCount != 0) {
                for (int i = 0; i != paramCount; ++i) {
                    string name = function.getParamOrVarName (i);
                    object val = i < args.Length ? args [i] : Undefined.Value;
                    DefineProperty (name, val, PERMANENT);
                }
            }

            // initialize "arguments" property but only if it was not overriden by
            // the parameter with the same name
            if (!base.Has ("arguments", this)) {
                DefineProperty ("arguments", new Arguments (this), PERMANENT);
            }

            if (paramAndVarCount != 0) {
                for (int i = paramCount; i != paramAndVarCount; ++i) {
                    string name = function.getParamOrVarName (i);
                    if (!base.Has (name, this)) {
                        DefineProperty (name, Undefined.Value, PERMANENT);
                    }
                }
            }
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:35,代码来源:BuiltinCall.cs


示例2: Call

 public override object Call (Context cx, IScriptable scope, IScriptable thisObj, object [] args)
 {
     if (script != null) {
         return script.Exec (cx, scope);
     }
     return Undefined.Value;
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:7,代码来源:BuiltinScript.cs


示例3: ToObject

 public static IScriptable ToObject (IScriptable scope, object val)
 {
     if (val is IScriptable) {
         return (IScriptable)val;
     }
     return ToObject (null, scope, val);
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:7,代码来源:ScriptConvert.cs


示例4: ExecIdCall

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

            if (id == Id_constructor) {
                bool b = ScriptConvert.ToBoolean (args, 0);
                if (thisObj == null) {
                    return new BuiltinBoolean (b);
                }
                return b;
            }

            // The rest of Boolean.prototype methods require thisObj to be Boolean

            if (!(thisObj is BuiltinBoolean))
                throw IncompatibleCallError (f);
            bool value = ((BuiltinBoolean)thisObj).booleanValue;

            switch (id) {

                case Id_toString:
                    return value ? "true" : "false";

                case Id_toSource:
                    return value ? "(new Boolean(true))" : "(new Boolean(false))";

                case Id_valueOf:
                    return value;
            }
            throw new ArgumentException (Convert.ToString (id));
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:34,代码来源:BuiltinBoolean.cs


示例5: ImportTypes

 public static void ImportTypes(IScriptable scope, string startsWith)
 {
     foreach (Assembly ass in Context.CurrentContext.AppDomain.GetAssemblies())
     {
         ImportAssembly(scope, ass, startsWith);
     }
 }
开发者ID:ikvm,项目名称:YUI-Compressor-.NET,代码行数:7,代码来源:CliPackage.cs


示例6: ImportAssembly

 public static void ImportAssembly(IScriptable scope, Assembly ass, string startsWith)
 {
     foreach (Type type in ass.GetTypes ()) {
         if (startsWith == null || type.FullName.StartsWith (startsWith))
             ImportType (scope, type);
     }
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:7,代码来源:CliPackage.cs


示例7: Put

 public override object Put (string id, IScriptable start, object value)
 {
     // Ignore assignments to "length"--it's readonly.
     if (!id.Equals ("length"))
         return base.Put (id, start, value);
     return Undefined.Value;
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:7,代码来源:CliArray.cs


示例8: BuiltinString

 internal static void Init
     (IScriptable scope, bool zealed)
 {
     BuiltinString obj = new BuiltinString ("");
     obj.ExportAsJSClass (MAX_PROTOTYPE_ID, scope, zealed, 
         ScriptableObject.DONTENUM | ScriptableObject.READONLY | ScriptableObject.PERMANENT);
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:7,代码来源:BuiltinString.cs


示例9: Call

 public override object Call (Context cx, IScriptable scope, IScriptable thisObj, object [] args)
 {
     if (args.Length > 0 && args [0] is BuiltinRegExp && (args.Length == 1 || args [1] == Undefined.Value)) {
         return args [0];
     }
     return Construct (cx, scope, args);
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:7,代码来源:BuiltinRegExpCtor.cs


示例10: Construct

 public override IScriptable Construct (Context cx, IScriptable scope, object [] args)
 {
     BuiltinRegExp re = new BuiltinRegExp ();
     re.compile (cx, scope, args);
     ScriptRuntime.setObjectProtoAndParent (re, scope);
     return re;
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:7,代码来源:BuiltinRegExpCtor.cs


示例11: ExecIdCall

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

                case Id_defaultSettings: {
                        lib.SetDefaultSettings ();
                        IScriptable obj = cx.NewObject (scope);
                        WriteSetting (obj);
                        return obj;
                    }

                case Id_settings: {
                        IScriptable obj = cx.NewObject (scope);
                        WriteSetting (obj);
                        return obj;
                    }

                case Id_setSettings: {
                        if (args.Length == 0 || args [0] == null || args [0] == Undefined.Value) {
                            lib.SetDefaultSettings ();
                        }
                        else if (args [0] is IScriptable) {
                            ReadSettings ((IScriptable)args [0]);
                        }
                        return Undefined.Value;
                    }
            }
            throw new System.ArgumentException (System.Convert.ToString (id));
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:33,代码来源:XMLCtor.cs


示例12: PythonEngine

        public PythonEngine(IScriptable callback)
        {
            _callback = callback;
            _scriptHandler = new ScriptHandler(_callback);

            _engines.Add(callback, this);
        }
开发者ID:mrommel,项目名称:MiRo.SimHexWorld,代码行数:7,代码来源:PythonEngine.cs


示例13: ExecIdCall

        public override object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args)
        {
            int id = f.MethodId;
            switch (id) {
                case Id_print:
                    for (int i = 0; i < args.Length; i++) {
                        if (i > 0)
                            Console.Out.Write (" ");
                        Console.Out.Write (ScriptConvert.ToString (args [i]));
                    }
                    Console.Out.WriteLine ();
                    return Undefined.Value;

                case Id_version:
                    if (args.Length > 0) {
                        if (CliHelper.IsNumber (args [0])) {
                            int newVer = (int)ScriptConvert.ToNumber (args [0]);
                            if (Context.IsValidLanguageVersion (newVer)) {
                                cx.Version = Context.ToValidLanguageVersion (newVer);
                            }
                        }
                    }
                    return (int)cx.Version;
                case Id_options:
                    StringBuilder sb = new StringBuilder ();
                    if (cx.HasFeature (Context.Features.Strict))
                        sb.Append ("strict");
                    return sb.ToString ();
                case Id_gc:
                    GC.Collect ();
                    return Undefined.Value;
            }
            throw f.Unknown ();
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:34,代码来源:BuiltinGlobalObject.cs


示例14: Put

 public override object Put (int index, IScriptable start, object value)
 {
     if (0 <= index && index < length) {
         ((System.Array)array).SetValue (Context.JsToCli (value, cls), index);
         return value;
     }
     return base.Put (index, start, value);
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:8,代码来源:CliArray.cs


示例15: Get

 public override object Get (int index, IScriptable start)
 {
     if (0 <= index && index < length) {
         object obj = ((System.Array)array).GetValue (index);
         return Context.CurrentContext.Wrap (this, obj, cls);
     }
     return Undefined.Value;
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:8,代码来源:CliArray.cs


示例16: Init

 internal static void Init (IScriptable scope, bool zealed)
 {
     BuiltinDate obj = new BuiltinDate ();
     // Set the value of the prototype Date to NaN ('invalid date');
     obj.date = double.NaN;
     obj.ExportAsJSClass (MAX_PROTOTYPE_ID, scope, zealed
         , ScriptableObject.DONTENUM | ScriptableObject.READONLY | ScriptableObject.PERMANENT);
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:8,代码来源:BuiltinDate.cs


示例17: Perform

        public virtual object Perform (Context cx, IScriptable scope, IScriptable thisObj, object [] args, RegExpActions actionType)
        {
            GlobData data = new GlobData ();
            data.mode = actionType;

            switch ( (RegExpActions)actionType) {

                case EcmaScript.NET.RegExpActions.Match: {
                        object rval;
                        data.optarg = 1;
                        rval = matchOrReplace (cx, scope, thisObj, args, this, data, false);
                        return data.arrayobj == null ? rval : data.arrayobj;
                    }


                case EcmaScript.NET.RegExpActions.Search:
                    data.optarg = 1;
                    return matchOrReplace (cx, scope, thisObj, args, this, data, false);


                case EcmaScript.NET.RegExpActions.Replace: {
                        object arg1 = args.Length < 2 ? Undefined.Value : args [1];
                        string repstr = null;
                        IFunction lambda = null;
                        if (arg1 is IFunction) {
                            lambda = (IFunction)arg1;
                        }
                        else {
                            repstr = ScriptConvert.ToString (arg1);
                        }

                        data.optarg = 2;
                        data.lambda = lambda;
                        data.repstr = repstr;
                        data.dollar = repstr == null ? -1 : repstr.IndexOf ((char)'$');
                        data.charBuf = null;
                        data.leftIndex = 0;
                        object val = matchOrReplace (cx, scope, thisObj, args, this, data, true);
                        SubString rc = this.rightContext;

                        if (data.charBuf == null) {
                            if (data.global || val == null || !val.Equals (true)) {
                                /* Didn't match even once. */
                                return data.str;
                            }
                            SubString lc = this.leftContext;
                            replace_glob (data, cx, scope, this, lc.index, lc.length);
                        }
                        data.charBuf.Append (rc.charArray, rc.index, rc.length);
                        return data.charBuf.ToString ();
                    }


                default:
                    throw Context.CodeBug ();

            }
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:58,代码来源:RegExpImpl.cs


示例18: Has

 public override bool Has (int index, IScriptable start)
 {
     if (0 <= index && index < args.Length) {
         if (args [index] != UniqueTag.NotFound) {
             return true;
         }
     }
     return base.Has (index, start);
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:9,代码来源:Arguments.cs


示例19: InitFunction

 public virtual void InitFunction (string name, IScriptable scope)
 {
     if (name == null)
         throw new ArgumentException ();
     if (scope == null)
         throw new ArgumentException ();
     this.functionName = name;
     ParentScope = scope;
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:9,代码来源:IdFunctionObject.cs


示例20: Init

        public static void Init (IScriptable scope)
        {
            CliPackage obj = new CliPackage ();

            ScriptableObject.DefineProperty (scope,
                "cli", obj, ScriptableObject.DONTENUM);

            obj.ParentScope = scope;
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:9,代码来源:CliPackage.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IScripture类代码示例发布时间:2022-05-24
下一篇:
C# IScriptModulePlugin类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap