public IEnumerable <ElementModelViewModel> GetLeafEnumerator() { if (IsLeaf) { return(new[] { this }); } return(ChildrenViewModels.SelectMany(x => x.GetLeafEnumerator())); }
public void RemoveSchema(ISchemaViewModel schema) { ChildrenViewModels.Remove(schema); if (typeof(FolderSchemaViewModel) == schema.GetType()) { Schema.Children.Remove((schema as FolderSchemaViewModel)._schema); } if (typeof(FileSchemaViewModel) == schema.GetType()) { Schema.Children.Remove((schema as FileSchemaViewModel).XmlSchema); } }
public void AddSchema(string mode, ObservableCollection <Models.XmlAnything <Models.ISchema> > schemaList) { if ("file" == mode) { FileSchemaViewModel newSchema = new FileSchemaViewModel(_mainSettings, new Models.FileSchema(), this, _log); Models.XmlAnything <Models.ISchema> xmlAnything = new Models.XmlAnything <Models.ISchema>(); xmlAnything.Value = newSchema.Schema; ChildrenViewModels.Add(newSchema); schemaList.Add(xmlAnything); } if ("folder" == mode) { FolderSchemaViewModel newSchema = new FolderSchemaViewModel(_mainSettings, new Models.FolderSchema(), this, _log); Models.XmlAnything <Models.ISchema> xmlAnything = new Models.XmlAnything <Models.ISchema>(); xmlAnything.Value = newSchema.Schema; ChildrenViewModels.Add(newSchema); schemaList.Add(xmlAnything); } }