protected virtual PropertyInfo GetModelIdPropertyInfo() { var modelType = typeof(TModel); var properties = modelType.GetProperties(); var modelIdProperty = properties.FirstOrDefault(x => HassSerializer.GetSerializedPropertyName(x) == this.modelIdPropertyName); return(modelIdProperty ?? properties.Where(x => x.Name.EndsWith("Id")).OrderBy(x => x.Name.Length).FirstOrDefault()); }
private string GetModelSerialized(JToken merged) { string modelSerialized = HassSerializer.SerializeObject(merged); var idPropertyName = HassSerializer.GetSerializedPropertyName(idPropertyInfo); if (this.modelIdPropertyName != idPropertyName) { modelSerialized = modelSerialized.Replace(this.modelIdPropertyName, idPropertyName); } return(modelSerialized); }