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


C# Context类代码示例

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


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

示例1: ExecTest

        static void ExecTest(Context context, IMatch testToken)
        {
            var token = new CaptureGroup(testToken);

            if(token.Match(context))
            {
                WriteInfo("Match success.");
                WriteLine(context);

                while (token.MatchNext(context))
                {
                    WriteInfo("MatchNext success.");
                    WriteLine(context);
                }
                WriteError("MatchNext failed.");
                WriteLine(context);
            }
            else
            {
                WriteError("Match failed.");
                WriteLine(context);
            }

            if (context.offset != 0)
                WriteError("Warning: Context offset not reset to 0.");
        }
开发者ID:TheFellow,项目名称:RegexLib,代码行数:26,代码来源:RegexTests.cs

示例2: ensures_same_deterministic_order_when_getting_entities_after_DestroyAllEntities

    public void ensures_same_deterministic_order_when_getting_entities_after_DestroyAllEntities()
    {
        var context = new Context(1);

        const int numEntities = 10;
        for (int i = 0; i < numEntities; i++) {
            context.CreateEntity();
        }

        var order1 = new int[numEntities];
        var entities1 = context.GetEntities();
        for (int i = 0; i < numEntities; i++) {
            order1[i] = entities1[i].creationIndex;
        }

        context.DestroyAllEntities();
        context.ResetCreationIndex();

        for (int i = 0; i < numEntities; i++) {
            context.CreateEntity();
        }

        var order2 = new int[numEntities];
        var entities2 = context.GetEntities();
        for (int i = 0; i < numEntities; i++) {
            order2[i] = entities2[i].creationIndex;
        }

        for (int i = 0; i < numEntities; i++) {
            var index1 = order1[i];
            var index2 = order2[i];

            Assert.AreEqual(index1, index2);
        }
    }
开发者ID:sschmid,项目名称:Entitas-CSharp,代码行数:35,代码来源:ContextTests.cs

示例3: StartListening

 private void StartListening()
 {
     context = new Context(1);
     socket = context.Socket(SocketType.PULL);
     socket.Connect("tcp://127.0.0.1:8400"); // Connect to 8400
     UpdateTextBox("Connected to 127.0.0.1:8400");
 }
开发者ID:dhendo,项目名称:ZMQ-Demo,代码行数:7,代码来源:MainWindow.xaml.cs

示例4: Parse

        /// <summary>
        /// Parse bytes in context into a FlaggedPropertyValueNode
        /// </summary>
        /// <param name="context">The value of Context</param>
        public override void Parse(Context context)
        {
            this.Flag = context.PropertyBytes[context.CurIndex++];
            switch (this.Flag)
            {
                // PropertyValue presents
                case 0:
                    break;

                // PropertyValue not presents
                case 1:
                    return;

                // Property error code
                case 0xA:

                    // If the Flag is 0x0A, the property type should be PtypErrorCode.
                    context.CurProperty.Type = PropertyType.PtypErrorCode;
                    break;

                // Not defined value
                default:
                    break;
            }
            
            base.Parse(context);
        }
开发者ID:ClareMSYanGit,项目名称:Interop-TestSuites,代码行数:31,代码来源:FlaggedPropertyValue.cs

示例5: ReadTemplateFile

			public string ReadTemplateFile(Context context, string templateName)
			{
				string templatePath = (string) context[templateName];

				switch (templatePath)
				{
					case "product":
						return "Product: {{ product.title }} ";

					case "locale_variables":
						return "Locale: {{echo1}} {{echo2}}";

					case "variant":
						return "Variant: {{ variant.title }}";

					case "nested_template":
						return "{% include 'header' %} {% include 'body' %} {% include 'footer' %}";

					case "body":
						return "body {% include 'body_detail' %}";

					case "nested_product_template":
						return "Product: {{ nested_product_template.title }} {%include 'details'%} ";

					case "recursively_nested_template":
						return "-{% include 'recursively_nested_template' %}";

					case "pick_a_source":
						return "from TestFileSystem";

					default:
						return templatePath;
				}
			}
开发者ID:nZeus,项目名称:dotliquid,代码行数:34,代码来源:IncludeTagTests.cs

示例6: GetAIStateClient

		protected AIStateClient GetAIStateClient(Context context)
		{
			if (Shmipl.StatePath.IsSubState(context.State, Phase.Auction))
				return new AIStateClient_Auction();

			if (context.armyFight != null || context.navyFight != null)
				return new AIStateClient_Fight();

			if (context.State.StartsWith("Turn.PlaceMetro"))
				return new AIStateClient_PlaceMetro(context.State.Equals("Turn.PlaceMetroBuilding"));

			switch (context.turn.CurrentGod)
			{
				case God.Zeus:
					return new AIStateClient_Zeus();
				case God.Sophia:
					return new AIStateClient_Sophia();
				case God.Poseidon:
					return new AIStateClient_Poseidon();
				case God.Mars:
					return new AIStateClient_Mars();
				case God.Appolon:
					return new AIStateClient_Apollo();
			}

			throw new Exception("AI: unknown GetAIStateClient");
		}
开发者ID:AciesNN,项目名称:cyc,代码行数:27,代码来源:AIClient.cs

示例7: TransportadorasController

 public TransportadorasController()
 {
     context = new Context();
     var dataBaseInitializer = new DataBaseInitializer();
     dataBaseInitializer.InitializeDatabase(context);
     repositorioTransportadora = new Repository<Transportadora>(context);
 }
开发者ID:maricrmacedo,项目名称:testeAxado,代码行数:7,代码来源:TransportadorasController.cs

示例8: Decode

        /// <summary>
        /// Decodes the specified instruction.
        /// </summary>
        /// <param name="ctx">The context.</param>
        /// <param name="decoder">The instruction decoder, which holds the code stream.</param>
        public override void Decode(Context ctx, IInstructionDecoder decoder)
        {
            // Decode base classes first
            base.Decode(ctx, decoder);

            Token token = decoder.DecodeTokenType();
            ITypeModule module = null;
            Mosa.Runtime.TypeSystem.Generic.CilGenericType genericType = decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType;
            if (genericType != null)
                module = (decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType).BaseGenericType.Module;
            else
                module = decoder.Method.Module;
            ctx.RuntimeField = module.GetField(token);

            if (ctx.RuntimeField.ContainsGenericParameter)
            {
                foreach (RuntimeField field in decoder.Method.DeclaringType.Fields)
                    if (field.Name == ctx.RuntimeField.Name)
                    {
                        ctx.RuntimeField = field;
                        break;
                    }

                Debug.Assert(!ctx.RuntimeField.ContainsGenericParameter);
            }

            SigType sigType = ctx.RuntimeField.SignatureType;
            ctx.Result = LoadInstruction.CreateResultOperand(decoder, Operand.StackTypeFromSigType(sigType), sigType);
        }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:34,代码来源:LdfldInstruction.cs

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

示例10: Set

 public object Set(Context cx, object value)
 {
     if (xmlObject == null)
         throw ScriptRuntime.UndefWriteError (this, ToString (), value);
     xmlObject.PutXMLProperty (this, value);
     return value;
 }
开发者ID:arifbudiman,项目名称:TridionMinifier,代码行数:7,代码来源:XMLName.cs

示例11: TestEncodeMessageWithAllFieldTypes

        public void TestEncodeMessageWithAllFieldTypes()
        {
            var template = new MessageTemplate(
                "",
                new Field[]
                    {
                        new Scalar("1", FastType.String, Operator.Copy, ScalarValue.Undefined, false),
                        new Scalar("2", FastType.ByteVector, Operator.Copy, ScalarValue.Undefined, false),
                        new Scalar("3", FastType.Decimal, Operator.Copy, ScalarValue.Undefined, false),
                        new Scalar("4", FastType.I32, Operator.Copy, ScalarValue.Undefined, false),
                        new Scalar("5", FastType.String, Operator.Copy, ScalarValue.Undefined, false),
                        new Scalar("6", FastType.U32, Operator.Copy, ScalarValue.Undefined, false),
                    });

            var context = new Context();
            context.RegisterTemplate(113, template);

            var message = new Message(template);
            message.SetString(1, "H");
            message.SetByteVector(2, new[] {(byte) 0xFF});
            message.SetDecimal(3, 1.201);
            message.SetInteger(4, -1);
            message.SetString(5, "abc");
            message.SetInteger(6, 2);

            //               --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6---
            const string msgstr =
                "11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010";
            AssertEquals(msgstr, new FastEncoder(context).Encode(message));
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:30,代码来源:FastEncoderTest.cs

示例12: InsertBlockProtectInstructions

        private void InsertBlockProtectInstructions()
        {
            foreach (var handler in MethodCompiler.Method.ExceptionHandlers)
            {
                var tryBlock = BasicBlocks.GetByLabel(handler.TryStart);

                var tryHandler = BasicBlocks.GetByLabel(handler.HandlerStart);

                var context = new Context(InstructionSet, tryBlock);

                while (context.IsEmpty || context.Instruction == IRInstruction.TryStart)
                {
                    context.GotoNext();
                }

                context.AppendInstruction(IRInstruction.TryStart, tryHandler);

                context = new Context(InstructionSet, tryHandler);

                if (handler.HandlerType == ExceptionHandlerType.Exception)
                {
                    var exceptionObject = MethodCompiler.CreateVirtualRegister(handler.Type);

                    context.AppendInstruction(IRInstruction.ExceptionStart, exceptionObject);
                }
                else if (handler.HandlerType == ExceptionHandlerType.Finally)
                {
                    context.AppendInstruction(IRInstruction.FinallyStart);
                }
            }
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:31,代码来源:ProtectedRegionStage.cs

示例13: ContinueCodelet

 public ContinueCodelet(double salience, Context context, IContinuation succ, IFailure fail)
     : base(context.Coderack, salience, 4 * 4, 5)
 {
     this.context = context;
     this.succ = succ;
     this.fail = fail;
 }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:7,代码来源:ContinueCodelet.cs

示例14: test_empty

        public static void test_empty()
        {
            var context = new Context("abc");
            var empty = new Empty();

            ExecTest(context, empty);
        }
开发者ID:TheFellow,项目名称:RegexLib,代码行数:7,代码来源:RegexTests.cs

示例15: Process

 public Process(Context context)
     : base(context)
 {
     Constructor = new ProcessConstructor(context, "Process", new ProcessInstance(context.Events.EventEmitter.InstancePrototype, false));
     Instance = Constructor.Construct();
     Populate();
 }
开发者ID:nagyistoce,项目名称:SharpJS,代码行数:7,代码来源:Process.cs


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