public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) { ObjectValue objectValue; if (reader.TokenType == JsonToken.StartObject) { ObjectValueAttributeSuperset superset = new ObjectValueAttributeSuperset(); serializer.Populate(reader, superset); ObjectValueType parsedObjectType; if (!Enum.TryParse(superset.objectType, true, out parsedObjectType)) { // If a new object type is introduced to the Smartsheet API that this version of the SDK doesn't support, // return null instead of throwing an exception. return(null); } switch (parsedObjectType) { case ObjectValueType.DURATION: objectValue = new Duration(superset.negative, superset.elapsed, superset.weeks, superset.days, superset.hours, superset.minutes, superset.seconds, superset.milliseconds); break; case ObjectValueType.PREDECESSOR_LIST: objectValue = new PredecessorList(superset.predecessors); break; case ObjectValueType.CONTACT: ContactObjectValue contactObjectValue = new ContactObjectValue(); contactObjectValue.Name = superset.name; contactObjectValue.Email = superset.email; contactObjectValue.Id = superset.id; contactObjectValue.RefIndex = superset.refIndex; contactObjectValue.ImageId = superset.imageId; objectValue = contactObjectValue; break; case ObjectValueType.DATE: case ObjectValueType.DATETIME: case ObjectValueType.ABSTRACT_DATETIME: objectValue = new DateObjectValue(parsedObjectType, superset.value); break; case ObjectValueType.MULTI_CONTACT: objectValue = new MultiContactObjectValue(superset.values); break; default: objectValue = null; break; } } else { if (reader.TokenType == JsonToken.Boolean) { objectValue = new BooleanObjectValue((bool)reader.Value); } else if (reader.TokenType == JsonToken.Integer) { objectValue = new NumberObjectValue(Convert.ToDouble(reader.Value)); } else if (reader.TokenType == JsonToken.Float) { objectValue = new NumberObjectValue((double)reader.Value); } else { objectValue = new StringObjectValue((string)reader.Value); } } return(objectValue); }
// Includes Email Authentication /*public APIRequests(String sheetName, string accessTokenIn, String GIS, * String userEmail, String name, String email, * String address, String city, String state, * String price, String phoneNum, DateTime date) * { * accessToken = accessTokenIn; * smartsheet = new SmartsheetBuilder() * .SetAccessToken(accessToken) * .SetAssumedUser(userEmail) * .Build(); * sheetID = this.getSheetID(sheetName); * * if (name != null) { this.name = name; } * if (address != null) { this.address = address; } * if (email != null) { this.email = email; } * if (phoneNum != null) { this.number = phoneNum; } * if (city != null) { this.city = city; } * if (state != null) { this.state = state; } * }*/ public void addRow(String name, String address, int phone, DateObjectValue date, String money) { }