public override JToken Serialize(JaBuilderContext context) { JObject template = GetTemplate(); List <string> propertiesToRemove = new List <string>(); foreach (var property in template.Properties()) { if (property.Name.Equals(Constants.KEY_RELATIONSHIPS)) { JToken jt = BuildRelationships(property.Value, context); if (jt == null || jt.IsEmpty()) { propertiesToRemove.Add(property.Name); } else { property.Value = jt; } } else { context.Populate(property, this); } } propertiesToRemove.ForEach(n => template.Remove(n)); return(template); }
public virtual JToken Serialize(JaBuilderContext context) { foreach (var property in template.Properties()) { context.Populate(property, this); } return(template); }