Exemplo n.º 1
0
        public void WriteByAttribute()
        {
            ObjectWithDefaultValue obj = new ObjectWithDefaultValue
            {
                Id        = 13,
                FirstName = "foo",
                LastName  = "bar",
                Age       = 12
            };

            const string hexBuffer = "A26249640D684C6173744E616D6563626172";

            Helper.TestWrite(obj, hexBuffer);
        }
Exemplo n.º 2
0
        public void WriteByAttribute()
        {
            JsonSerializerOptions options = new JsonSerializerOptions();

            options.SetupExtensions();

            var obj = new ObjectWithDefaultValue
            {
                Id        = 13,
                FirstName = "foo",
                LastName  = "bar",
                Age       = 12
            };

            const string json = @"{""Id"":13,""LastName"":""bar""}";

            Helper.TestWrite(obj, json, options);
        }
Exemplo n.º 3
0
        /// <summary>
        /// default不是萬解
        /// </summary>
        public void ObjectSetDefault()
        {
            //init 就會塞入預設值
            var obj = new ObjectWithDefaultValue()
            {
                numberInt = 223
            };

            //當我另外給她空值 這個就沒有用了
            obj.ValueIsString   = null;
            obj.ValuelikeString = null;

            //這樣也不行 反正就是如果你有給東西 就會複寫預設值
            //呼叫物件實 不可為null的要自己判斷虛實
            var obj2 = new ObjectWithDefaultValue()
            {
                ValueIsString   = null,
                ValuelikeString = null,
            };
            var a = obj2;
        }