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


C# NET.Context类代码示例

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


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


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