download:Coroutine principles are high performance development techniques that are required for every back-end development from beginner to master
Coroutine knowledge is covered in many courses, but it is only superficial and not in-depth. As the first special course on coroutines in the market, this course will start from the basics and link with the application principles. It will be easier to understand the principles of coroutines in depth. It will use Python language for practical practice combined with rich course cases. No matter you are a Java, Go or PHP developer, you can master the coroutine principle through this course. It is a very suitable course for beginners to learn high performance development.
It is suitable for students who want to master the underlying principles of process, thread and coroutine to break through the business bottleneck and improve the concurrent ability of the project. Public class ObjectIdConverter public class ObjectIdConverter public class ObjectIdConverter JsonConverter { public override bool CanConvert(Type objectType) { return objectType == typeof(ObjectId); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType ! = JsonToken.String) { throw new Exception( String.Format(“Unexpected token parsing ObjectId. Expected String, got {0}.”, reader.TokenType)); } var value = (string)reader.Value; return String.IsNullOrEmpty(value) ? ObjectId.Empty : new ObjectId(value); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { if (value is ObjectId) { var objectId = (ObjectId)value; writer.WriteValue(objectId ! = ObjectId.Empty ? objectId.ToString() : String.Empty); } else { throw new Exception(“Expected ObjectId value.”); Add a line of code to the ObjectId field
[JsonConverter(typeof(ObjectIdConverter))] public string _id { get; set; } If Newtonsoft’s JsonConvert is used, additional parameters are required
JsonConvert.DeserializeObject(json,new ObjectIdConverter());
3, after Ignore, a very skillful writing method
[JsonIgnore] public override ObjectId _Id { get; set; } [BsonIgnore] public string _IdStr { get { return Id.ToString(); } set { ObjectId id; ObjectId.TryParse(value, out id); Id = id; }}