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


C# DynamicDictionary类代码示例

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


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

示例1: HomeModule

        public HomeModule(ITransient transient, IRequestScoped requestScoped)
            : base("/home")
        {
            _transient = transient;
            _requestScoped = requestScoped;
            Debug.Assert(_requestScoped == _transient.RequestScoped);

            Get["/"] = _ =>
            {
                var viewBag = new DynamicDictionary();
                viewBag.Add("Transient", _transient);
                viewBag.Add("RequestScoped", _requestScoped);
                return View["home/index", viewBag];
            };

            Get["/index", runAsync: true] = async (_, token) =>
            {
                await Task.Delay(1000);
                return "123";
            };

            Get["/list", runAsync: true] = async (_, token) =>
            {
                await Task.Delay(1);
                return 500;
            };

            Get["/edit", runAsync: true] = async (_, token) =>
            {
                await Task.Delay(1);
                return 404;
            };
        }
开发者ID:lcssk8board,项目名称:DryIoc-Nancy,代码行数:33,代码来源:HomeModule.cs

示例2: Can_read_non_existing_value_from_dictionary_via_dynamic_object

		public void Can_read_non_existing_value_from_dictionary_via_dynamic_object()
		{
			var dictionary = new Dictionary<string, object>();
			dynamic adapter = new DynamicDictionary(dictionary);

			Assert.IsNull(adapter.Name);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:7,代码来源:DynamicDictionaryTests.cs

示例3: MainModule

		public MainModule()
		{
			Get["/"] = x => View["index.html"];

            Get["/login"] = x =>
            {
                dynamic model = new DynamicDictionary();
                model.Errored = this.Request.Query.error.HasValue;

                return View["login", model];
            };

            Post["/login"] = x =>
            {
                var userGuid = UserDatabase.ValidateUser((string)this.Request.Form.Username, (string)this.Request.Form.Password);

                if (userGuid == null)
                {
                    return this.Context.GetRedirect("~/login?error=true&username=" + (string)this.Request.Form.Username);
                }

                DateTime? expiry = null;
                if (this.Request.Form.RememberMe.HasValue)
                {
                    expiry = DateTime.Now.AddDays(7);
                }

                return this.LoginAndRedirect(userGuid.Value, expiry);
            };

            Get["/logout"] = x =>
            {
                return this.LogoutAndRedirect("~/");
            };
		}
开发者ID:cbsistem,项目名称:JRIAppTS,代码行数:35,代码来源:MainModule.cs

示例4: TmMqMessage

        public TmMqMessage( ITmMqMessage copy )
        {
            #region param checks
            if( copy == null )
            {
                throw new ArgumentNullException( "copy" );
            }
            #endregion

            MessageId = copy.MessageId;
            Properties = new DynamicDictionary( copy.Properties );
            Errors = new List<TmMqMessageError>( copy.Errors );
            TimeStamp = copy.TimeStamp;
            DeliveredAt = copy.DeliveredAt;

            CorrelationId = copy.CorrelationId;
            RetryCount = copy.RetryCount;
            DeliveryCount = copy.DeliveryCount;
            Type = copy.Type;
            OriginalQueue = copy.OriginalQueue;
            ReplyTo = copy.ReplyTo;
            Text = copy.Text;
            ExpireAt = copy.ExpireAt;
            HoldUntil = copy.HoldUntil;
        }
开发者ID:RabidArts,项目名称:TrivialMongoMessageQueue,代码行数:25,代码来源:TmMqMessage.cs

示例5: Invoke

        /// <summary>
        /// Invokes the specified <paramref name="route"/> with the provided <paramref name="parameters"/>.
        /// </summary>
        /// <param name="route">The route that should be invoked.</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <param name="parameters">The parameters that the route should be invoked with.</param>
        /// <param name="context">The context of the route that is being invoked.</param>
        /// <returns>A <see cref="Response"/> instance that represents the result of the invoked route.</returns>
        public async Task<Response> Invoke(Route route, CancellationToken cancellationToken, DynamicDictionary parameters, NancyContext context)
        {
            object result;

            try
            {
                result = await route.Invoke(parameters, cancellationToken).ConfigureAwait(false);
            }
            catch(RouteExecutionEarlyExitException earlyExitException)
            {
                context.WriteTraceLog(
                    sb => sb.AppendFormat(
                            "[DefaultRouteInvoker] Caught RouteExecutionEarlyExitException - reason {0}",
                            earlyExitException.Reason));
                return earlyExitException.Response;
            }

            if (!(result is ValueType) && result == null)
            {
                context.WriteTraceLog(
                    sb => sb.AppendLine("[DefaultRouteInvoker] Invocation of route returned null"));

                result = new Response();
            }

            return this.negotiator.NegotiateResponse(result, context);
        }
开发者ID:RadifMasud,项目名称:Nancy,代码行数:35,代码来源:DefaultRouteInvoker.cs

示例6: Accessing_A_Defined_Property_Should_Return_The_Defined_Value

        public void Accessing_A_Defined_Property_Should_Return_The_Defined_Value()
        {
            dynamic obj = new DynamicDictionary();

            obj.FirstName = "Clark";

            Assert.That( obj.FirstName == "Clark" );
        }
开发者ID:randyburden,项目名称:Sequelocity.NET,代码行数:8,代码来源:DynamicDictionaryTests.cs

示例7: ShouldBeAbleToSetAndRetrievePropertyViaIndexer

        public void ShouldBeAbleToSetAndRetrievePropertyViaIndexer()
        {
            var dictionary = new DynamicDictionary();

            dictionary["key"] = "value";

            Assert.AreEqual("value", dictionary["key"]);
        }
开发者ID:ReactiveMarkets,项目名称:Styx,代码行数:8,代码来源:DynamicDictionaryTests.cs

示例8: Can_read_from_dictionary_via_dynamic_object

		public void Can_read_from_dictionary_via_dynamic_object()
		{
			var dictionary = new Dictionary<string, object>();
			dynamic adapter = new DynamicDictionary(dictionary);
			dictionary["Name"] = "stefan mucha";

			Assert.AreEqual("stefan mucha", adapter.Name);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:8,代码来源:DynamicDictionaryTests.cs

示例9: Can_add_to_dictionary_via_dynamic_object

		public void Can_add_to_dictionary_via_dynamic_object()
		{
			var dictionary = new Dictionary<string, object>();
			dynamic adapter = new DynamicDictionary(dictionary);
			adapter.Name = "stefan mucha";

			Assert.AreEqual("stefan mucha", dictionary["Name"]);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:8,代码来源:DynamicDictionaryTests.cs

示例10: Accessing_A_Not_Existent_Property_Should_Return_Null

        public void Accessing_A_Not_Existent_Property_Should_Return_Null()
        {
            dynamic obj = new DynamicDictionary();

            var firstName = obj.FirstName;

            Assert.Null( firstName );
        }
开发者ID:randyburden,项目名称:Sequelocity.NET,代码行数:8,代码来源:DynamicDictionaryTests.cs

示例11: A_Defined_Anonymous_Object_Should_Be_Accessible_Dynamically

        public void A_Defined_Anonymous_Object_Should_Be_Accessible_Dynamically()
        {
            dynamic obj = new DynamicDictionary();

            obj.Customer = new { FirstName = "Clark", LastName = "Kent" };

            Assert.That( obj.Customer.FirstName == "Clark" );
        }
开发者ID:randyburden,项目名称:Sequelocity.NET,代码行数:8,代码来源:DynamicDictionaryTests.cs

示例12: The_DynamicDictionary_Should_Be_Castable_To_An_IDictionary_Of_String_Object

        public void The_DynamicDictionary_Should_Be_Castable_To_An_IDictionary_Of_String_Object()
        {
            dynamic obj = new DynamicDictionary();

            var dictionary = (IDictionary<string, object>)obj;

            Assert.NotNull( dictionary );
        }
开发者ID:randyburden,项目名称:Sequelocity.NET,代码行数:8,代码来源:DynamicDictionaryTests.cs

示例13: TestContainsKey

        public void TestContainsKey()
        {
            var d = new DynamicDictionary();

            d.Add("key", "value");

            Assert.IsTrue(d.ContainsKey("key"), "Did not contain key: \"key\"");
        }
开发者ID:harunpehlivan,项目名称:LiveSDK-for-Windows,代码行数:8,代码来源:DynamicDictionaryTest.cs

示例14: TestAdd

        public void TestAdd()
        {
            var d = new DynamicDictionary();

            d.Add("key", "value");

            Assert.AreEqual("value", d["key"]);
        }
开发者ID:harunpehlivan,项目名称:LiveSDK-for-Windows,代码行数:8,代码来源:DynamicDictionaryTest.cs

示例15: ResolveResult

 public ResolveResult(Route route, DynamicDictionary parameters, Func<NancyContext, Response> before, Action<NancyContext> after, Func<NancyContext, Exception, Response> onError)
 {
     this.Route = route;
     this.Parameters = parameters;
     this.Before = before;
     this.After = after;
     this.OnError = onError;
 }
开发者ID:kppullin,项目名称:Nancy,代码行数:8,代码来源:ResolveResult.cs


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