private static void AddChildren(MetadataItem model, PageViewModel result) { if (model.Items != null && model.Items.Count > 0) { foreach (var item in model.Items) { result.Items.Add(ItemViewModel.FromModel(item)); AddChildren(item, result); } } }
public static PageViewModel FromModel(MetadataItem model) { if (model == null) { return(null); } var result = new PageViewModel(); result.Items.Add(ItemViewModel.FromModel(model)); if (model.Type.AllowMultipleItems()) { AddChildren(model, result); } foreach (var item in model.References) { result.References.Add(ReferenceViewModel.FromModel(item)); } return(result); }