コード例 #1
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            if (type != typeof(TestConverterType))
            {
                return(null);
            }

            var data = new TestConverterType();

            data.Data = Convert.ToInt32(dictionary["DataValue"]);

            return(data);
        }
コード例 #2
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            TestConverterType data = obj as TestConverterType;

            if (data == null)
            {
                return(null);
            }

            var fields = new Dictionary <string, object>();

            fields["DataValue"] = data.Data;

            return(fields);
        }