public IDataTree Create(IDataTree tree, IMapCategory mapCategory) { object instance = mapCategory.Parent.IsCollapsed ? mapCategory.ResolveInstance(mapCategory.Parent.ResolveInstance(tree.Instance)) : mapCategory.ResolveInstance(tree.Instance); return(mapCategory.OwnerType == typeof(DataTree) ? (DataTree)instance : new DataTree(instance, mapCategory)); }
public void ResolveInstance() { var mapper = new CategoriesMapper(); IMapCategory construction = mapper.Construct <MainItem>(); MainItem main = new MainItem(); Assert.AreEqual(main, construction.ResolveInstance(main)); Assert.AreEqual(main.SubCat, construction.Categories.First().ResolveInstance(main)); }