handle add column request (#1272)

* handle add column request

* comments

* rename data to ViewModel
This commit is contained in:
Alan Ren
2021-10-19 09:54:57 -07:00
committed by GitHub
parent 791c3594a9
commit 192f7fccd4
18 changed files with 310 additions and 83 deletions

View File

@@ -3,6 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
@@ -27,8 +28,41 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
{
public DesignerEditType Type { get; set; }
[JsonConverter(typeof(TableDesignerPropertyConverter))]
public object Property { get; set; }
public object Value { get; set; }
}
/// <summary>
/// The property "Property" of <c>TableDesignerChangeInfo</c> could be string or <c>TableDesignerPropertyIdentifier</c>, use this custom converter to set the property value.
/// </summary>
public class TableDesignerPropertyConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return true;
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
object property;
if (reader.TokenType == JsonToken.StartObject)
{
TableDesignerPropertyIdentifier obj = serializer.Deserialize(reader, typeof(TableDesignerPropertyIdentifier)) as TableDesignerPropertyIdentifier;
property = obj;
}
else
{
property = reader.Value;
}
return property;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
// We don't need to serialize this class.
throw new NotImplementedException();
}
}
}