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

C# NET.Context类代码示例

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

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



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

示例1: 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


示例2: Delete

 public bool Delete(Context cx)
 {
     if (type == Types.None) {
         return ScriptRuntime.deleteObjectElem (target, name, cx);
     }
     return false;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:7,代码来源:SpecialRef.cs


示例3: 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


示例4: Add

 // neg:
 // implement the '-' operator inline in the caller
 // as "-ScriptConvert.ToNumber(val)"
 // not:
 // implement the '!' operator inline in the caller
 // as "!toBoolean(val)"
 // bitnot:
 // implement the '~' operator inline in the caller
 // as "~toInt32(val)"
 public static object Add(object val1, object val2, Context cx)
 {
     if (CliHelper.IsNumber (val1) && CliHelper.IsNumber (val2)) {
         return (double)val1 + (double)val2;
     }
     if (val1 is XMLObject) {
         object test = ((XMLObject)val1).AddValues (cx, true, val2);
         if (test != UniqueTag.NotFound) {
             return test;
         }
     }
     if (val2 is XMLObject) {
         object test = ((XMLObject)val2).AddValues (cx, false, val1);
         if (test != UniqueTag.NotFound) {
             return test;
         }
     }
     if (val1 is EcmaScript.NET.Types.Cli.CliEventInfo) {
         return ((EcmaScript.NET.Types.Cli.CliEventInfo)val1).Add (val2, cx);
     }
     if (val1 is IScriptable)
         val1 = ((IScriptable)val1).GetDefaultValue (null);
     if (val2 is IScriptable)
         val2 = ((IScriptable)val2).GetDefaultValue (null);
     if (!(val1 is string) && !(val2 is string))
         if ((CliHelper.IsNumber (val1)) && (CliHelper.IsNumber (val2)))
             return (double)val1 + (double)val2;
         else
             return ScriptConvert.ToNumber (val1) + ScriptConvert.ToNumber (val2);
     return string.Concat (ScriptConvert.ToString (val1), ScriptConvert.ToString (val2));
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:40,代码来源:ScriptRuntime.cs


示例5: createSpecial

        internal static IRef createSpecial (Context cx, object obj, string name)
        {
            IScriptable target = ScriptConvert.ToObjectOrNull (cx, obj);
            if (target == null) {
                throw ScriptRuntime.UndefReadError (obj, name);
            }

            Types type;
            if (name.Equals ("__proto__")) {
                type = Types.Proto;
            }
            else if (name.Equals ("__parent__")) {
                type = Types.Parent;
            }
            else {
                throw new ArgumentException (name);
            }

            if (!cx.HasFeature (Context.Features.ParentProtoProperties)) {
                // Clear special after checking for valid name!
                type = Types.None;
            }

            return new SpecialRef (target, type, name);
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:25,代码来源:SpecialRef.cs


示例6: Has

 public bool Has(Context cx)
 {
     if (type == Types.None) {
         return ScriptRuntime.hasObjectElem (target, name, cx);
     }
     return true;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:7,代码来源:SpecialRef.cs


示例7: InterpreterData

        internal InterpreterData(Context.Versions languageVersion, string sourceFile, string encodedSource)
        {
            this.languageVersion = languageVersion;
            this.itsSourceFile = sourceFile;
            this.encodedSource = encodedSource;

            Init ();
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:8,代码来源:InterpreterData.cs


示例8: 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


示例9: ToObjectOrNull

 public static IScriptable ToObjectOrNull (Context cx, object obj)
 {
     if (obj is IScriptable) {
         return (IScriptable)obj;
     }
     else if (obj != null && obj != Undefined.Value) {
         return ToObject (cx, ScriptRuntime.getTopCallScope (cx), obj);
     }
     return null;
 }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:10,代码来源:ScriptConvert.cs


示例10: InitStandardObjects

        public static ScriptableObject InitStandardObjects (Context cx, ScriptableObject scope, bool zealed)
        {
            if (scope == null) {
                scope = new BuiltinObject ();
            }
            scope.AssociateValue (LIBRARY_SCOPE_KEY, scope);

            BaseFunction.Init (scope, zealed);
            BuiltinObject.Init (scope, zealed);

            IScriptable objectProto = ScriptableObject.GetObjectPrototype (scope);

            // Function.prototype.__proto__ should be Object.prototype
            IScriptable functionProto = ScriptableObject.GetFunctionPrototype (scope);
            functionProto.SetPrototype (objectProto);

            // Set the prototype of the object passed in if need be
            if (scope.GetPrototype () == null)
                scope.SetPrototype (objectProto);

            // must precede NativeGlobal since it's needed therein
            BuiltinError.Init (scope, zealed);
            BuiltinGlobal.Init (cx, scope, zealed);

            if (scope is BuiltinGlobalObject) {
                ((BuiltinGlobalObject)scope).Init (scope, zealed);
            }

            BuiltinArray.Init (scope, zealed);
            BuiltinString.Init (scope, zealed);
            BuiltinBoolean.Init (scope, zealed);
            BuiltinNumber.Init (scope, zealed);
            BuiltinDate.Init (scope, zealed);
            BuiltinMath.Init (scope, zealed);

            BuiltinWith.Init (scope, zealed);
            BuiltinCall.Init (scope, zealed);
            BuiltinScript.Init (scope, zealed);

            BuiltinRegExp.Init (scope, zealed);

            if (cx.HasFeature (Context.Features.E4x)) {
                Types.E4X.XMLLib.Init (scope, zealed);
            }

            Continuation.Init (scope, zealed);
        
            if (cx.HasFeature (Context.Features.NonEcmaItObject)) {
                InitItObject (cx, scope);
            }

            return scope;
        }
开发者ID:hazzik,项目名称:EcmaScript.NET,代码行数:53,代码来源:ScriptRuntime.cs


示例11: IdEnumeration

        public IdEnumeration (object value, Context cx, bool enumValues)
        {
            obj = ScriptConvert.ToObjectOrNull (cx, value);
            if (obj != null) {
                // null or undefined do not cause errors but rather lead to empty
                // "for in" loop
                this.enumValues = enumValues;

                // enumInit should read all initial ids before returning
                // or "for (a.i in a)" would wrongly enumerate i in a as well
                ChangeObject ();
            }
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:13,代码来源:IdEnumeration.cs


示例12: ExecIdCall

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

                case Id_constructor:
                    throw Context.ReportRuntimeError ("Direct call is not supported");
            }
            throw new ArgumentException (Convert.ToString (id));
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:13,代码来源:Continuation.cs


示例13: initFromContext

        public virtual void initFromContext (Context cx)
        {
            setErrorReporter (cx.ErrorReporter);
            this.languageVersion = cx.Version;
            useDynamicScope = cx.compileFunctionsWithDynamicScopeFlag;
            generateDebugInfo = (!cx.GeneratingDebugChanged || cx.GeneratingDebug);
            reservedKeywordAsIdentifier = cx.HasFeature (Context.Features.ReservedKeywordAsIdentifier);
            allowMemberExprAsFunctionName = cx.HasFeature (Context.Features.MemberExprAsFunctionName);
            xmlAvailable = cx.HasFeature (Context.Features.E4x);
            getterAndSetterSupport = cx.HasFeature (Context.Features.GetterAndSetter);

            optimizationLevel = cx.OptimizationLevel;

            generatingSource = cx.GeneratingSource;
            activationNames = cx.activationNames;
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:16,代码来源:CompilerEnvirons.cs


示例14: Get

        public object Get (Context cx)
        {
            switch (type) {

                case Types.None:
                    return ScriptRuntime.getObjectProp (target, name, cx);

                case Types.Proto:
                    return target.GetPrototype ();

                case Types.Parent:
                    return target.ParentScope;

                default:
                    throw Context.CodeBug ();

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


示例15: Current

        public virtual object Current(Context cx)
        {
            if (!enumValues)
                return currentId;

            object result;

            string s = ScriptRuntime.ToStringIdOrIndex (cx, currentId);
            if (s == null) {
                int index = ScriptRuntime.lastIndexResult (cx);
                result = obj.Get (index, obj);
            }
            else {
                result = obj.Get (s, obj);
            }

            return result;
        }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:18,代码来源:IdEnumeration.cs


示例16: Set

        public object Set (Context cx, object value)
        {
            switch (type) {

                case Types.None:
                    return ScriptRuntime.setObjectProp (target, name, value, cx);

                case Types.Proto:
                case Types.Parent: {
                        IScriptable obj = ScriptConvert.ToObjectOrNull (cx, value);
                        if (obj != null) {
                            // Check that obj does not contain on its prototype/scope
                            // chain to prevent cycles
                            IScriptable search = obj;
                            do {
                                if (search == target) {
                                    throw Context.ReportRuntimeErrorById ("msg.cyclic.value", name);
                                }
                                if (type == Types.Proto) {
                                    search = search.GetPrototype ();
                                }
                                else {
                                    search = search.ParentScope;
                                }
                            }
                            while (search != null);
                        }
                        if (type == Types.Proto) {
                            target.SetPrototype (obj);
                        }
                        else {
                            target.ParentScope = obj;
                        }
                        return obj;
                    }

                default:
                    throw Context.CodeBug ();

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


示例17: Parse

        public static Namespace Parse (XMLLib lib, Context cx, Object prefixValue,
            Object uriValue)
        {
            String prefix;
            String uri;

            if (uriValue is QName) {
                QName qname = (QName)uriValue;
                uri = qname.Uri;
                if (uri == null) {
                    uri = qname.ToString ();
                }
            }
            else {
                uri = ScriptConvert.ToString (uriValue);
            }

            if (uri.Length == 0) {
                if (prefixValue == Undefined.Value) {
                    prefix = "";
                }
                else {
                    prefix = ScriptConvert.ToString (prefixValue);
                    if (prefix.Length != 0) {
                        throw ScriptRuntime.TypeError (
                            "Illegal prefix '" + prefix + "' for 'no namespace'.");
                    }
                }
            }
            else if (prefixValue == Undefined.Value) {
                prefix = "";
            }
            else if (!lib.IsXMLName (cx, prefixValue)) {
                prefix = "";
            }
            else {
                prefix = ScriptConvert.ToString (prefixValue);
            }

            return new Namespace (lib, prefix, uri);
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:41,代码来源:Namespace.cs


示例18: jsConstructor

        private object jsConstructor (Context cx, bool inNewExpr, object [] args)
        {
            if (!inNewExpr && args.Length == 1) {
                return Namespace.Parse (lib, cx, args [0]);
            }

            if (args.Length == 0) {
                return Namespace.Parse (lib, cx);
            }
            else if (args.Length == 1) {
                return Namespace.Parse (lib, cx, args [0]);
            }
            else {
                return Namespace.Parse (lib, cx, args [0], args [1]);
            }
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:16,代码来源:Namespace.cs


示例19: ExecIdCall

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

                case Id_constructor:
                    return jsConstructor (cx, (thisObj == null), args);

                case Id_toString:
                    return realThis (thisObj, f).ToString ();

                case Id_toSource:
                    return realThis (thisObj, f).js_toSource ();
            }
            throw new System.ArgumentException (System.Convert.ToString (id));
        }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:19,代码来源:Namespace.cs


示例20: CallMethod

 /// <summary> Call a method of an object.</summary>
 /// <param name="cx">the Context object associated with the current thread.
 /// </param>
 /// <param name="obj">the JavaScript object
 /// </param>
 /// <param name="methodName">the name of the function property
 /// </param>
 /// <param name="args">the arguments for the call
 /// </param>
 public static object CallMethod (Context cx, IScriptable obj, string methodName, object [] args)
 {
     object funObj = GetProperty (obj, methodName);
     if (!(funObj is IFunction)) {
         throw ScriptRuntime.NotFunctionError (obj, methodName);
     }
     IFunction fun = (IFunction)funObj;
     // TODO: What should be the scope when calling funObj?
     // The following favor scope stored in the object on the assumption
     // that is more useful especially under dynamic scope setup.
     // An alternative is to check for dynamic scope flag
     // and use ScriptableObject.getTopLevelScope(fun) if the flag is not
     // set. But that require access to Context and messy code
     // so for now it is not checked.
     IScriptable scope = ScriptableObject.GetTopLevelScope (obj);
     if (cx != null) {
         return fun.Call (cx, scope, obj, args);
     }
     else {
         return Context.Call (null, fun, scope, obj, args);
     }
 }
开发者ID:rumincayman,项目名称:EcmaScript.NET,代码行数:31,代码来源:ScriptableObject.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# NET.Node类代码示例发布时间:2022-05-24
下一篇:
C# Objects.EcellObject类代码示例发布时间: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