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


C# TestObjects.Movie类代码示例

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


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

示例1: CreatePropertySetter

        public void CreatePropertySetter()
        {
            Action<object, object> setter = ExpressionReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

            Movie m = new Movie();

            setter(m, "OH HAI!");

            Assert.AreEqual("OH HAI!", m.Name);
        }
开发者ID:KenoraTechnologies,项目名称:Newtonsoft.Json,代码行数:10,代码来源:ExpressionReflectionDelegateFactoryTests.cs

示例2: CreateSetWithBadObjectTarget

    public void CreateSetWithBadObjectTarget()
    {
      Person p = new Person();
      Movie m = new Movie();

      Action<object, object> setter = DynamicReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

      setter(m, "Hi");

      Assert.AreEqual(m.Name, "Hi");

      setter(p, "Hi");
    }
开发者ID:adrianhewitt,项目名称:to-Screenshot-Generator,代码行数:13,代码来源:DynamicReflectionDelegateFactoryTests.cs

示例3: CreateSetWithBadObjectTarget

    public void CreateSetWithBadObjectTarget()
    {
      ExceptionAssert.Throws<InvalidCastException>("Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.",
      () =>
      {
        Person p = new Person();
        Movie m = new Movie();

        Action<object, object> setter = DynamicReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

        setter(m, "Hi");

        Assert.AreEqual(m.Name, "Hi");

        setter(p, "Hi");
      });
    }
开发者ID:bladefist,项目名称:Newtonsoft.Json,代码行数:17,代码来源:DynamicReflectionDelegateFactoryTests.cs

示例4: NullValueHandlingBlogPost

    public void NullValueHandlingBlogPost()
    {
      Movie movie = new Movie();
      movie.Name = "Bad Boys III";
      movie.Description = "It's no Bad Boys";

      string included = JsonConvert.SerializeObject(movie,
        Formatting.Indented,
        new JsonSerializerSettings { });

      // {
      //   "Name": "Bad Boys III",
      //   "Description": "It's no Bad Boys",
      //   "Classification": null,
      //   "Studio": null,
      //   "ReleaseDate": null,
      //   "ReleaseCountries": null
      // }

      string ignored = JsonConvert.SerializeObject(movie,
        Formatting.Indented,
        new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

      // {
      //   "Name": "Bad Boys III",
      //   "Description": "It's no Bad Boys"
      // }

      Assert.AreEqual(@"{
  ""Name"": ""Bad Boys III"",
  ""Description"": ""It's no Bad Boys"",
  ""Classification"": null,
  ""Studio"": null,
  ""ReleaseDate"": null,
  ""ReleaseCountries"": null
}", included);

      Assert.AreEqual(@"{
  ""Name"": ""Bad Boys III"",
  ""Description"": ""It's no Bad Boys""
}", ignored);
    }
开发者ID:Gert-Cominotto,项目名称:MvvmCross,代码行数:42,代码来源:NullValueHandlingTests.cs

示例5: CreateSetWithBadObjectValue

    public void CreateSetWithBadObjectValue()
    {
      ExceptionAssert.Throws<InvalidCastException>("Unable to cast object of type 'System.Version' to type 'System.String'.",
      () =>
      {
        Movie m = new Movie();

        Action<object, object> setter = DynamicReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

        setter(m, new Version("1.1.1.1"));
      });
    }
开发者ID:bladefist,项目名称:Newtonsoft.Json,代码行数:12,代码来源:DynamicReflectionDelegateFactoryTests.cs

示例6: CreateSetWithBadObjectValue

    public void CreateSetWithBadObjectValue()
    {
      Movie m = new Movie();

      Action<object, object> setter = DynamicReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

      setter(m, new Version());
    }
开发者ID:adrianhewitt,项目名称:to-Screenshot-Generator,代码行数:8,代码来源:DynamicReflectionDelegateFactoryTests.cs

示例7: CreateSetWithBadObjectValue

        public void CreateSetWithBadObjectValue()
        {
            ExceptionAssert.Throws<InvalidCastException>(
                () => {
                    Movie m = new Movie();

                    Action<object, object> setter = ExpressionReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

                    setter(m, new Version("1.1.1.1"));
                }, new [] { 
                    "Unable to cast object of type 'System.Version' to type 'System.String'.",
                    "Cannot cast from source type to destination type." //mono
                });
        }
开发者ID:Redth,项目名称:Newtonsoft.Json,代码行数:14,代码来源:ExpressionReflectionDelegateFactoryTests.cs

示例8: CreateSetWithBadObjectTarget

        public void CreateSetWithBadObjectTarget()
        {
            ExceptionAssert.Throws<InvalidCastException>(
                () => {
                    Person p = new Person();
                    Movie m = new Movie();

                    Action<object, object> setter = ExpressionReflectionDelegateFactory.Instance.CreateSet<object>(typeof(Movie).GetProperty("Name"));

                    setter(m, "Hi");

                    Assert.AreEqual(m.Name, "Hi");

                    setter(p, "Hi");

                    Assert.AreEqual(p.Name, "Hi");
                },
                new [] {
                    "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.",
                    "Cannot cast from source type to destination type." // mono
                });
        }
开发者ID:Redth,项目名称:Newtonsoft.Json,代码行数:22,代码来源:ExpressionReflectionDelegateFactoryTests.cs

示例9: CreateMethodCall

        public void CreateMethodCall()
        {
            MethodCall<object, object> method = ExpressionReflectionDelegateFactory.Instance.CreateMethodCall<object>(typeof(Movie).GetMethod("ToString"));

            Movie m = new Movie();
            object result = method(m);
            Assert.AreEqual("Newtonsoft.Json.Tests.TestObjects.Movie", result);

            method = ExpressionReflectionDelegateFactory.Instance.CreateMethodCall<object>(typeof(Movie).GetMethod("Equals"));

            result = method(m, m);
            Assert.AreEqual(true, result);
        }
开发者ID:Redth,项目名称:Newtonsoft.Json,代码行数:13,代码来源:ExpressionReflectionDelegateFactoryTests.cs

示例10: CreatePropertyGetter

        public void CreatePropertyGetter()
        {
            Func<object, object> getter = ExpressionReflectionDelegateFactory.Instance.CreateGet<object>(typeof(Movie).GetProperty("Name"));

            Movie m = new Movie();
            m.Name = "OH HAI!";

            object value = getter(m);

            Assert.AreEqual("OH HAI!", value);
        }
开发者ID:Redth,项目名称:Newtonsoft.Json,代码行数:11,代码来源:ExpressionReflectionDelegateFactoryTests.cs


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