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


C# Scope.Get方法代码示例

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


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

示例1: SupportDotedNamesForJson

        public void SupportDotedNamesForJson()
        {
            var cfg = new Scope();
            cfg.Set("a", new {b=1});
            var cfg2 = new Scope(cfg);
            cfg2.Set("a", new {b=3});

            Assert.AreEqual(3, cfg2.Get("a.b"));
            Assert.AreEqual(1, cfg2.Get(".a.b"));
        }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:10,代码来源:ScopeImprovementsTest.cs

示例2: Invoke

        public dynamic Invoke(Scope scope)
        {
            if(Id == "undefined")
                return new Undefined();
            else if (Id == "null")
                return new Null();

            return scope.Get(Id, IsMember);
        }
开发者ID:Diullei,项目名称:Shion,代码行数:9,代码来源:Identifier.cs

示例3: Evaluate

        public override Value Evaluate(Scope scope, TextWriter output)
        {
            Value  value;

            if (scope.Get (this.name, out value))
                return value;

            return UndefinedValue.Instance;
        }
开发者ID:WMeszar,项目名称:Cottle,代码行数:9,代码来源:NameExpression.cs

示例4: Create

 public XElement Create(string uri, XElement current, IScope scope) {
     scope = new Scope(scope);
     scope["store_render"] = true;
     scope["render_name"] = "render_result";
     scope["no_render"] = true;
     Render(null, scope, null);
     var result = scope.Get<XElement>("render_result");
     if (null == result) {
         throw new Exception("component not processed");
     }
     return result;
 }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:12,代码来源:ReportRenderBase.cs

示例5: PerformService

        public override ResponseMessage PerformService(Scope<object> clientSessionScope)
        {
            var sessionManagerMap =
                (DictionaryList<object, WebSocketClientSessionManager>)
                clientSessionScope.Get(SessionObjects.SessionsMap);

            string sessionId = (string) clientSessionScope.Get(SessionObjects.SessionId);

            ChatUpdate messageUpdate = new ChatUpdate(message, sessionId);

            foreach (WebSocketClientSessionManager otherClient in sessionManagerMap.Values)
            {
                Console.WriteLine(otherClient.SessionId + "Checking to make sure not " + sessionId);
                if (!otherClient.SessionId.Equals(sessionId))
                {
                    otherClient.SendUpdateToClient(messageUpdate, otherClient.SessionId);
                }
            }

            return OkResponse.ReusableInstance;
        }
开发者ID:ecologylab,项目名称:WebSocketOODSSTutorial,代码行数:21,代码来源:ChatRequest.cs

示例6: ProcessUpdate

        public override void ProcessUpdate(Scope<object> objectRegistry)
        {
            var listener = (ITestServiceUpdateListener) objectRegistry.Get(TestServiceConstants.ServiceUpdateListener);

            if (listener != null)
            {
                listener.OnReceiveUpdate(this);
            }
            else
            {
                throw new NullReferenceException("cannot find client in application scope");
            }
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:13,代码来源:TestServiceUpdate.cs

示例7: ProcessUpdate

 public override void ProcessUpdate(Scope<object> applicationObjectScope)
 {
     //get lisener from applicationobjacetscope
     var listener = (ChatUpdateListener) applicationObjectScope.Get(ChatConstants.ChatUpdateLisener);
     //call the listener's receive update
     if (listener != null)
     {
         listener.ReceivedUpdate(this);
     }
     else
     {
         Console.WriteLine("Listener not set in application scope. Can't display message from\n"+ id + ": " + message);
     }
 }
开发者ID:ecologylab,项目名称:WebSocketOODSSTutorial,代码行数:14,代码来源:ChatUpdate.cs

示例8: ParseParameters

        public static List<AstNodeExpr> ParseParameters(InstructionInfo InstructionInfo, Scope<string, AstLocal> Scope)
        {
            var Array = new List<AstNodeExpr>();

            MatchArgument.Replace(InstructionInfo.Name, (Match) =>
            {
                var MatchStr = Match.ToString();
                switch (MatchStr)
                {
                    case "%nn":
                        Array.Add(
                            (new AstNodeExprLocal(Scope.Get("%n2")) * 256) |
                            new AstNodeExprLocal(Scope.Get("%n1"))
                        );
                        break;
                    default:
                        Array.Add(new AstNodeExprLocal(Scope.Get(MatchStr)));
                        break;
                }
                return "";
            });

            return Array;
        }
开发者ID:soywiz-emulation,项目名称:cscpu,代码行数:24,代码来源:InstructionTable.Tools.cs

示例9: Invoke

        public dynamic Invoke(Scope scope)
        {
            var newScope = new Scope();

            // copy global scope
            //if(scope.IsGlobal)
            {
                scope.CloneVarSet(newScope);
                //foreach (var m in scope.VarSet) { newScope.VarSet[m.Key] = m.Value; }
                scope.CloneThisSet(newScope);
                //foreach (var m in scope.ThisSet) { newScope.ThisSet[m.Key] = m.Value; }
                scope.CloneFunctionSet(newScope);
                //foreach (var m in scope.FunctionSet) { newScope.FunctionSet[m.Key] = m.Value; }
            }

            var index = 0;
            if (Arguments != null)
                Arguments.ForEach(a =>
                {
                    try
                    {
                        newScope.SetArgument(((Identifier)Arguments[index]).Id, ((Literal)a).Value);
                    }
                    catch (Exception)
                    {
                        newScope.SetArgument(Guid.NewGuid().ToString(), ((Literal)a).Value);
                    }
                    index++;
                });

            var id = ((Identifier)Callee).Id;
            FunctionDef fn = scope.Get(id);

            fn.SetArgs(Arguments);

            var result = fn.Invoke(newScope);

            return result;
        }
开发者ID:Diullei,项目名称:Shion,代码行数:39,代码来源:NewExpression.cs

示例10: Invoke

        public dynamic Invoke(Scope scope)
        {
            if (Callee is MemberExpression)
            {
                (Callee as MemberExpression).Arguments = Arguments;
                return (Callee as MemberExpression).Invoke(scope);
            }

            var isNative = false;
            var result = Native.GetIfIsNative(Callee, null, ref isNative);
            if (isNative)
                return result;

            if(Callee is Identifier)
            {
                var id = ((Identifier) Callee).Id;
                FunctionDef fn = scope.Get(id);

                fn.SetArgs(Arguments);
                return fn.Invoke(scope);
            }

            throw new Exception("Invalid Call Expression");
        }
开发者ID:Diullei,项目名称:Shion,代码行数:24,代码来源:CallExpression.cs

示例11: ParseParameters

 public static List<AstNodeExpr> ParseParameters(InstructionInfo InstructionInfo, Scope<string, AstLocal> Scope)
 {
     var Parameters = new List<AstNodeExpr>();
     new Regex(@"%\w+").Replace(InstructionInfo.Format, (Match) =>
     {
         switch (Match.ToString())
         {
             case "%addr": Parameters.Add(ast.Cast<ushort>(ast.Local(Scope.Get("nnn")))); break;
             case "%vx": Parameters.Add(ast.Cast<byte>(ast.Local(Scope.Get("x")))); break;
             case "%vy": Parameters.Add(ast.Cast<byte>(ast.Local(Scope.Get("y")))); break;
             case "%byte": Parameters.Add(ast.Cast<byte>(ast.Local(Scope.Get("nn")))); break;
             case "%nibble": Parameters.Add(ast.Cast<byte>(ast.Local(Scope.Get("n")))); break;
             default: throw (new Exception(Match.ToString()));
         }
         return "";
     });
     return Parameters;
 }
开发者ID:soywiz-emulation,项目名称:cscpu,代码行数:18,代码来源:InstructionTable.cs

示例12: _Process

        public static AstNodeStm _Process(InstructionInfo InstructionInfo, Scope<string, AstLocal> Scope)
        {
            //Mnemonic = Mnemonic.Trim();
            //var Parts = Mnemonic.Split(new [] {' ' }, 2);
            Match Match;

            var Opcode = InstructionInfo.Name;
            var Param = InstructionInfo.Format;

            switch (Opcode)
            {
                case "ADC": case "SBC": case "ADD": case "SUB":
                    if ((Match = (GetRegex(@"^(A|HL|IX|IY),(SP|BC|DE|HL|IX|IY|A|B|C|D|E|H|L|IXh|IXl|IYh|IYl|\(HL\)|(\((IX|IY)\+%d\))|%n)$")).Match(Param)).Success)
                    {
                        var LeftRegister = Match.Groups[1].Value;
                        var RightRegister = Match.Groups[2].Value;
                        bool withCarry = (new[] { "ADC", "SBC" }).Contains(Opcode);
                        bool isSub = (new[] { "SUB", "SBC" }).Contains(Opcode);

                        MethodInfo doArithmeticMethod;
                        if (LeftRegister == "A")
                        {
                            doArithmeticMethod = ((Func<CpuContext, byte, byte, bool, bool, byte>)Z80InterpreterImplementation.doArithmeticByte).Method;
                        }
                        else
                        {
                            doArithmeticMethod = ((Func<CpuContext, ushort, ushort, bool, bool, ushort>)Z80InterpreterImplementation.doArithmeticWord).Method;
                        }

                        return ast.Assign(
                            GetRegister(LeftRegister),
                            ast.CallStatic(doArithmeticMethod, GetCpuContext(), GetRegister(LeftRegister), ParseRightRegister(RightRegister, Scope), withCarry, isSub)
                        );
                    }
                break;
                case "CP":
                    if ((Match = (GetRegex(@"^(A|B|C|D|E|H|L|IXh|IXl|IYh|IYl)$")).Match(Param)).Success)
                    {
                        var Register = Match.Groups[1].Value;
                        return ast.Statements(
                            ast.Statement(ast.CallStatic(
                                (Func<CpuContext, byte, byte, bool, bool, byte>)Z80InterpreterImplementation.doArithmeticByte,
                                GetCpuContext(), GetRegister("A"), GetRegister(Register), false, true
                            )),
                            ast.Statement(ast.CallStatic(
                                (Action<CpuContext, byte>)Z80InterpreterImplementation.adjustFlags,
                                GetCpuContext(), GetRegister(Register)
                            ))
                        );
                    }

                    if ((Match = (GetRegex(@"^\(HL\)$")).Match(Param)).Success)
                    {
                        return ast.Statement(ast.CallStatic(
                            (Func<CpuContext, byte>)Z80InterpreterImplementation.doCP_HL,
                            GetCpuContext()
                        ));
                    }
                    if ((Match = (GetRegex(@"^(%n)$")).Match(Param)).Success)
                    {
                        return ast.Statements(
                            ast.Assign(GetRegister("A"), ast.CallStatic((Func<CpuContext, byte, byte, bool, bool, byte>)Z80InterpreterImplementation.doArithmeticByte, GetCpuContext(), GetRegister("A"), GetNByte(Scope), false, true)),
                            ast.Statement(ast.CallStatic((Action<CpuContext, byte>)Z80InterpreterImplementation.adjustFlags, GetCpuContext(), GetNByte(Scope)))
                        );
                    }
                    break;
                // (RLC|RRC|RL|RR)
                case "RLC": case "RRC": case "RL": case "RR":
                    {
                        var FuncName = "do" + Opcode;
                        if ((Match = (GetRegex(@"^\(HL\)$")).Match(Param)).Success)
                        {
                            return WriteMemory1(
                                GetRegister("HL"),
                                ast.CallStatic(typeof(Z80InterpreterImplementation).GetMethod(FuncName), GetCpuContext(), true, ReadMemory1(GetRegister("HL")))
                            );
                        }
                        if ((Match = (GetRegex(@"^(A|B|C|D|E|H|L|IXh|IXl|IYh|IYl)$")).Match(Param)).Success)
                        {
                            var Register = Match.Groups[1].Value;
                            return ast.Assign(
                                GetRegister(Register),
                                ast.CallStatic(typeof(Z80InterpreterImplementation).GetMethod(FuncName), GetCpuContext(), true, GetRegister(Register))
                            );
                        }
                    }
                    break;
                case "RLA": case "RRA": case "RLCA": case "RRCA":
                    if ((Match = (GetRegex(@"^(RL|RR|RLC|RRC)A$")).Match(Opcode)).Success)
                    {
                        var FName = "do" + Match.Groups[1].Value;
                        var doMethod = typeof(Z80InterpreterImplementation).GetMethod(FName);
                        if (doMethod == null) throw (new Exception("Can't find method '" + FName + "'"));
                        return ast.Assign(GetRegister("A"), ast.CallStatic(doMethod, GetCpuContext(), false, GetRegister("A")));
                    }
                    break;
                case "AND": case "XOR": case "OR":
                    if ((Match = (GetRegex(@"^(\(HL\)|A|B|C|D|E|H|L|IXh|IXl|IYh|IYl|%n|(\((IX|IY)\+%d\)))$")).Match(Param)).Success)
                    {
                        var RightRegister = Match.Groups[1].Value;
//.........这里部分代码省略.........
开发者ID:soywiz-emulation,项目名称:cscpu,代码行数:101,代码来源:InstructionTable.Tools.cs

示例13: ParseRightRegister

 private static AstNodeExpr ParseRightRegister(string RightRegister, Scope<string, AstLocal> Scope)
 {
     switch (RightRegister)
     {
         case "(HL)":  case "(IX+%d)": case "(IY+%d)": return ReadMemory1(ParseRightAddress(RightRegister, Scope));
         case "%n": return ast.Cast<byte>(ast.Local(Scope.Get("%n")));
         default: return GetRegister(RightRegister);
     }
 }
开发者ID:soywiz-emulation,项目名称:cscpu,代码行数:9,代码来源:InstructionTable.Tools.cs

示例14: ParseRightAddress

 private static AstNodeExpr ParseRightAddress(string RightRegister, Scope<string, AstLocal> Scope)
 {
     switch (RightRegister)
     {
         case "(HL)": return GetRegister("HL");
         case "(IX+%d)": return ast.Cast<ushort>(ast.Cast<int>(GetRegister("IX")) + ast.Cast<int>(ast.Local(Scope.Get("%d"))));
         case "(IY+%d)": return ast.Cast<ushort>(ast.Cast<int>(GetRegister("IY")) + ast.Cast<int>(ast.Local(Scope.Get("%d"))));
         //case "IX": return ast.Cast<ushort>(ast.Cast<int>(GetRegister("IX")) + ast.Cast<int>(ast.Local(Scope.Get("%d"))));
         //case "IY": return ast.Cast<ushort>(ast.Cast<int>(GetRegister("IY")) + ast.Cast<int>(ast.Local(Scope.Get("%d"))));
         default: throw (new NotImplementedException("Invalid reference instruction"));
     }
 }
开发者ID:soywiz-emulation,项目名称:cscpu,代码行数:12,代码来源:InstructionTable.Tools.cs

示例15: GetNNWord

 private static AstNodeExpr GetNNWord(Scope<string, AstLocal> Scope)
 {
     return ast.Cast<ushort>(ast.Binary(ast.Local(Scope.Get("%n1")), "|", ast.Binary(ast.Local(Scope.Get("%n2")), "<<", 8)));
 }
开发者ID:soywiz-emulation,项目名称:cscpu,代码行数:4,代码来源:InstructionTable.Tools.cs


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