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

C# Context类代码示例

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

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



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


示例16: UserPage

 /******************************************/
 /******************************************/
 /// <summary>内部生成時、使用される</summary>
 /// <param name="Target">ターゲットユーザー</param>
 /// <param name="Host">生成元</param>
 /// <param name="Context">コンテキスト</param>
 internal UserPage(User.User Target, VideoService Host, Context Context)
 {
     target = Target;
     host = Host;
     context = Context;
     converter = new Serial.Converter(context);
 }
开发者ID:cocop,项目名称:NicoServiceAPI,代码行数:13,代码来源:UserPage.cs


示例17: FillChecks

	void FillChecks (Context cr, int x, int y, int width, int height)
	{
		int CHECK_SIZE = 32;
		
		cr.Save ();
		Surface check = cr.Target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
		
		// draw the check
		using (Context cr2 = new Context (check)) {
			cr2.Operator = Operator.Source;
			cr2.Color = new Color (0.4, 0.4, 0.4);
			cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
			cr2.Fill ();

			cr2.Color = new Color (0.7, 0.7, 0.7);
			cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE);
			cr2.Fill ();

			cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE);
			cr2.Fill ();
		}

		// Fill the whole surface with the check
		SurfacePattern check_pattern = new SurfacePattern (check);
		check_pattern.Extend = Extend.Repeat;
		cr.Source = check_pattern;
		cr.Rectangle (0, 0, width, height);
		cr.Fill ();

		check_pattern.Destroy ();
		check.Destroy ();
		cr.Restore ();
	}
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:33,代码来源:CairoSample.cs


示例18: Run

        protected override void Run()
        {
            Dictionary<Operand, int> list = new Dictionary<Operand, int>();

            foreach (var block in this.BasicBlocks)
            {
                for (var context = new Context(this.InstructionSet, block); !context.IsBlockEndInstruction; context.GotoNext())
                {
                    context.Marked = false;

                    if (context.Result == null)
                        continue;

                    int index = 0;

                    if (list.TryGetValue(context.Result, out index))
                    {
                        InstructionSet.Data[index].Marked = true;
                        context.Marked = true;
                    }
                    else
                    {
                        list.Add(context.Result, context.Index);
                    }
                }
            }
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:27,代码来源:MultipleDefinitionMarkerStage.cs


示例19: RequestPolicyWithBody

        public void RequestPolicyWithBody()
        {
            // Assert
            var requestMessage = new HttpRequestMessage()
            {
                RequestUri = new Uri("http://example.org/foo"),
                Content = new StringContent("Hello World!")
            };

            var variables = new Dictionary<string, object>()
            {
                { "message-id","xxxyyy"}
            };

            var context = new Context(requestMessage: requestMessage, variables: variables);

            // Act
            string policyResult = SendRequestToEventHub(context);

            //Assert
            Assert.Equal("request:xxxyyy\n"
                                        + "GET /foo HTTP/1.1\r\n"
                                        + "Host: example.org\r\n"
                                        + "Content-Type: text/plain; charset=utf-8\r\n"
                                        + "Content-Length: 12\r\n"
                                        + "\r\n"
                                        + "Hello World!", policyResult);
        }
开发者ID:darrelmiller,项目名称:ApimEventProcessor,代码行数:28,代码来源:PolicyTests.cs


示例20: Render

        /// <summary>
        /// Renders a tokens representation (or interpolated lambda result)
        /// </summary>
        /// <param name="writer">The writer to write the token to</param>
        /// <param name="context">The context to discover values from</param>
        /// <param name="partials">The partial templates available to the token</param>
        /// <param name="originalTemplate">The original template</param>
        /// <returns>The rendered token result</returns>
        public string Render(Writer writer, Context context, IDictionary<string, string> partials, string originalTemplate)
        {
            var value = context.Lookup(Value);
            value = InterpolateLambdaValueIfPossible(value, writer, context, partials);

            return value?.ToString();
        }
开发者ID:StubbleOrg,项目名称:Stubble,代码行数:15,代码来源:UnescapedValueToken.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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