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


C# System.Collections.Generic.GetType方法代码示例

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


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

示例1: Should_render_include_with_same_model

        public void Should_render_include_with_same_model()
        {
            var model = new { Name = "Joe" };
            RegisterTemplate("person", SyntaxTree.Block(
                SyntaxTree.WriteExpression(SyntaxTreeExpression.Property(model.GetType(), "Name"))
            ));
            var template = SyntaxTree.Block(
                SyntaxTree.WriteString("Hello "),
                SyntaxTree.Include("person", SyntaxTreeExpression.Self(model.GetType()))
            );

            var result = ExecuteTemplate(template, model);
            Assert.That(result, Is.EqualTo("Hello Joe"));
        }
开发者ID:namics,项目名称:TerrificNet,代码行数:14,代码来源:IncludeTests.cs

示例2: Should_map_an_anonymous_object_to_the_settings

        public void Should_map_an_anonymous_object_to_the_settings()
        {
            var converterCache = new DynamicObjectConverterCache(new DynamicImplementationBuilder());
            var cache = new DictionaryConverterCache();

            var source = new
                {
                    Host = "localhost",
                    VirtualHost = "vortex",
                    Username = "joe",
                    Password = "guess",
                    Port = 5672,
                };

            IDictionaryConverter converter = cache.GetConverter(source.GetType());
            IDictionary<string, object> dictionary = converter.GetDictionary(source);

            IObjectConverter objectConverter = converterCache.GetConverter(typeof(RabbitMqSettings));

            var settings = (RabbitMqSettings)objectConverter.GetObject(dictionary);

            Assert.IsNotNull(settings);

            Assert.AreEqual("localhost", settings.Host);
            Assert.AreEqual("vortex", settings.VirtualHost);
            Assert.AreEqual("joe", settings.Username);
            Assert.AreEqual("guess", settings.Password);
            Assert.AreEqual(5672, settings.Port);
            Assert.AreEqual(0, settings.Heartbeat);

            Assert.IsNull(settings.Options);
        }
开发者ID:kinpro,项目名称:RapidTransit,代码行数:32,代码来源:RabbitMqSettings_Specs.cs

示例3: Should_render_include_with_same_sub_model

        public void Should_render_include_with_same_sub_model()
        {
            var model = new { Name = "Joe", Company = new { Name = "Foo" } };
            RegisterTemplate("company", SyntaxTree.Block(
                SyntaxTree.WriteExpression(SyntaxTreeExpression.Property(model.Company.GetType(), "Name"))
            ));
            RegisterTemplate("person", SyntaxTree.Block(
                SyntaxTree.WriteExpression(SyntaxTreeExpression.Property(model.GetType(), "Name"))
            ));
            var template = SyntaxTree.Block(
                SyntaxTree.WriteString("Welcome from "),
                SyntaxTree.Include("company", SyntaxTreeExpression.Property(model.GetType(), "Company")),
                SyntaxTree.WriteString(" the amazing "),
                SyntaxTree.Include("person", SyntaxTreeExpression.Self(model.GetType())),
                SyntaxTree.WriteString(".")
            );

            var result = ExecuteTemplate(template, model);
            Assert.That(result, Is.EqualTo("Welcome from Foo the amazing Joe."));
        }
开发者ID:namics,项目名称:TerrificNet,代码行数:20,代码来源:IncludeTests.cs

示例4: Should_use_items_from_collection_as_scope

 public void Should_use_items_from_collection_as_scope()
 {
     var model = new { Items = new[] { new ItemModel { Name = "John" }, new ItemModel { Name = "Kim" } } };
     var template = SyntaxTree.Block(SyntaxTree.Iterate(
         SyntaxTreeExpression.Property(model.GetType(), "Items"),
         SyntaxTree.Block(
             SyntaxTree.WriteExpression(SyntaxTreeExpression.Property(typeof(ItemModel), "Name"))
         )
     ));
     var result = ExecuteTemplate(template, model);
     Assert.That(result, Is.EqualTo("JohnKim"));
 }
开发者ID:namics,项目名称:TerrificNet,代码行数:12,代码来源:IterateTests.cs

示例5: Should_throw_if_unable_to_load_template

        public void Should_throw_if_unable_to_load_template()
        {
            var model = new { Name = "Joe" };
            var template = SyntaxTree.Block(
                SyntaxTree.WriteString("Hello "),
                SyntaxTree.Include("person", SyntaxTreeExpression.Self(model.GetType()))
            );

            Assert.Throws<VeilCompilerException>(() =>
            {
                ExecuteTemplate(template, model);
            });
        }
开发者ID:namics,项目名称:TerrificNet,代码行数:13,代码来源:IncludeTests.cs

示例6: Should_be_able_to_output_value_types_from_collections

        public void Should_be_able_to_output_value_types_from_collections()
        {
            var model = new { Items = new[] { "1", "2", "3", "4" } };
            var template = SyntaxTree.Block(SyntaxTree.Iterate(
                SyntaxTreeExpression.Property(model.GetType(), "Items"),
                SyntaxTree.Block(
                    SyntaxTree.WriteExpression(SyntaxTreeExpression.Self(typeof(string)))
                )
            ));

            var result = ExecuteTemplate(template, model);
            Assert.That(result, Is.EqualTo("1234"));
        }
开发者ID:namics,项目名称:TerrificNet,代码行数:13,代码来源:IterateTests.cs

示例7: SholdKnowIfATypeIsAListOfResources

        public void SholdKnowIfATypeIsAListOfResources()
        {
            var list = new List<IBehaveAsResource>();
            var array = new[] {new SomeResource()};

            var notAResourceList = new List<int>();
            var notAResourceArray = new[] {1, 2};

            Assert.IsTrue(list.GetType().IsAListOfResources());
            Assert.IsTrue(array.GetType().IsAListOfResources());

            Assert.IsFalse(notAResourceList.GetType().IsAListOfResources());
            Assert.IsFalse(notAResourceArray.GetType().IsAListOfResources());
        }
开发者ID:seixasfelipe,项目名称:restfulie.net,代码行数:14,代码来源:TypeExtensionsTests.cs

示例8: Should_be_able_to_iterate_an_array

        public void Should_be_able_to_iterate_an_array()
        {
            var model = new { Items = new[] { "1", "2" } };
            var template = SyntaxTree.Block(SyntaxTree.Iterate(
                SyntaxTreeExpression.Property(model.GetType(), "Items"),
                SyntaxTree.Block(
                    SyntaxTree.WriteString("Item")
                ),
                SyntaxTree.Block(
                    SyntaxTree.WriteString("Empty")
                )
            ));

            var result = ExecuteTemplate(template, model);
            Assert.That(result, Is.EqualTo("ItemItem"));
        }
开发者ID:namics,项目名称:TerrificNet,代码行数:16,代码来源:IterateTests.cs

示例9: Root_model_of_template_should_be_the_model_executed_against

        public void Root_model_of_template_should_be_the_model_executed_against()
        {
            var model = new { Name = "Joe", Company = new { Name = "Foo", Departments = new[] { "IT", "Admin" } } };
            RegisterTemplate("company", SyntaxTree.Block(
                SyntaxTree.WriteExpression(SyntaxTreeExpression.Property(model.Company.GetType(), "Name")),
                SyntaxTree.WriteString(" - "),
                SyntaxTree.Iterate(SyntaxTreeExpression.Property(model.Company.GetType(), "Departments"), SyntaxTree.Block(
                    SyntaxTree.WriteExpression(SyntaxTreeExpression.Property(model.Company.GetType(), "Name", ExpressionScope.RootModel))
                ))
            ));
            var template = SyntaxTree.Block(
                SyntaxTree.Include("company", SyntaxTreeExpression.Property(model.GetType(), "Company"))
            );

            var result = ExecuteTemplate(template, model);
            Assert.That(result, Is.EqualTo("Foo - FooFoo"));
        }
开发者ID:namics,项目名称:TerrificNet,代码行数:17,代码来源:IncludeTests.cs

示例10: Does_encode_unicode

        public void Does_encode_unicode()
        {
            string test = "<\"I get this : 􏰁􏰂􏰃􏰄􏰂􏰅􏰆􏰇􏰈􏰀􏰉􏰊􏰇􏰋􏰆􏰌􏰀􏰆􏰊􏰀􏰍􏰄􏰎􏰆􏰏􏰐􏰑􏰑􏰆􏰒􏰆􏰂􏰊􏰀";
            var obj = new { test };
            using (var mem = new System.IO.MemoryStream())
            {
                ServiceStack.Text.JsonSerializer.SerializeToStream(obj, obj.GetType(), mem);

                var encoded = System.Text.Encoding.UTF8.GetString(mem.ToArray());

                var copy1 = JsonObject.Parse(encoded);

                Assert.That(test, Is.EqualTo(copy1["test"]));

                System.Diagnostics.Debug.WriteLine(copy1["test"]);
            }
        }
开发者ID:ServiceStack,项目名称:ServiceStack.Text,代码行数:17,代码来源:JsonObjectTests.cs

示例11: Should_be_able_to_extend_a_template

        public void Should_be_able_to_extend_a_template()
        {
            var model = new { Name = "Bob" };
            RegisterTemplate("master", SyntaxTree.Block(
                SyntaxTree.WriteString("<html><head>"),
                SyntaxTree.Override("head"),
                SyntaxTree.WriteString("</head></html>")
            ));
            var template = SyntaxTree.Extend("master", new Dictionary<string, SyntaxTreeNode> {
                {
                    "head",
                    SyntaxTree.Block(
                        SyntaxTree.WriteString("<title>"),
                        SyntaxTree.WriteExpression(SyntaxTreeExpression.Property(model.GetType(), "Name")),
                        SyntaxTree.WriteString("</title>")
                    )
                }
            });
            var result = ExecuteTemplate(template, model);

            Assert.That(result, Is.EqualTo("<html><head><title>Bob</title></head></html>"));
        }
开发者ID:namics,项目名称:TerrificNet,代码行数:22,代码来源:ExtendTests.cs

示例12: AnonObjectIsNotSimpleType

 public void AnonObjectIsNotSimpleType()
 {
     var dummyObject = new { id = 1, Name = "fred" };
     Assert.That(reader.IsSimpleType(dummyObject.GetType()), Is.False);
 }
开发者ID:nestalk,项目名称:MvcRouteTester,代码行数:5,代码来源:PropertyReaderIsSimpleTypeTests.cs

示例13: Should_render_empty_block_no_items_in_collection

        public void Should_render_empty_block_no_items_in_collection()
        {
            var model = new { Items = new List<string> { } };
            var template = SyntaxTree.Block(SyntaxTree.Iterate(
                SyntaxTreeExpression.Property(model.GetType(), "Items"),
                SyntaxTree.Block(
                    SyntaxTree.WriteString("Item")
                ),
                SyntaxTree.Block(
                    SyntaxTree.WriteString("Empty")
                )
            ));

            var result = ExecuteTemplate(template, model);
            Assert.That(result, Is.EqualTo("Empty"));
        }
开发者ID:namics,项目名称:TerrificNet,代码行数:16,代码来源:IterateTests.cs

示例14: GetFlowAuths

 public IList<dynamic> GetFlowAuths(decimal flowId)
 {
     using (var ctx = new OAContext())
     {
         var x = new
         {
             flow_id = 1m,
             auth_to = 1m,
             auth_to_name = ""
         };
         var t = x.GetType();
         var re = ctx.SqlDynamic(string.Format(@"
     select fa.*,nvl(o.org_name,'') || nvl(d.dept_name,'') || nvl(r.role_name,'') as auth_name from t_flow_auth fa left join t_org o on fa.auth_to = o.org_id
     left join t_dept d on fa.auth_to = d.dept_id
     left join t_role r on fa.auth_to = r.role_id
     where fa.flow_id={0}", flowId));
         return re;
     }
 }
开发者ID:fengxingshi,项目名称:CZJC,代码行数:19,代码来源:FlowCtrl+-+复制.cs


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