private CollectionMenuModel FindOrCreateCollection(CollectionMenuModel model, string[] fragments) { var childModel = (CollectionMenuModel)model.Children.FirstOrDefault(child => child.Name == fragments[0]); if (childModel == null) { childModel = new FolderMenuModel(fragments[0], null, fragments[0]); model.AddModel(childModel); } if (fragments.Length > 1) { var fragmentsLessOne = new string[fragments.Length - 1]; Array.ConstrainedCopy(fragments, 1, fragmentsLessOne, 0, fragmentsLessOne.Length); return(FindOrCreateCollection(childModel, fragmentsLessOne)); } return(childModel); }
private CollectionMenuModel FindOrCreateCollection(CollectionMenuModel model, string[] fragments) { var childModel = (CollectionMenuModel) model.Children.FirstOrDefault(child => child.Name == fragments[0]); if (childModel == null) { childModel = new FolderMenuModel(fragments[0], null, fragments[0]); model.AddModel(childModel); } if (fragments.Length > 1) { var fragmentsLessOne = new string[fragments.Length - 1]; Array.ConstrainedCopy(fragments, 1, fragmentsLessOne, 0, fragmentsLessOne.Length); return FindOrCreateCollection(childModel, fragmentsLessOne); } return childModel; }