public AssetNodeViewModel(Asset asset, PackageDatabaseTreeViewModel parent, CompositionContainer container)
     : base(asset, parent, container, asset.Type)
 {
     this.Name = asset.Key;
     this.Model = asset;
 }
 public PackageDatabaseNodeViewModel(PackageDatabaseTreeViewModel parent, CompositionContainer container, IPackageRepository repository)
     :base (null, parent, container, AssetTypes.PacakgeDatabase)
 {
     foreach (var package in repository.Packages.OrderBy(x => x.Name))
     {
         this.AddChild(new PackageNodeViewModel(package, parent, container, repository));
     }         
 }
        public PackageNodeViewModel(Package package, PackageDatabaseTreeViewModel parent, CompositionContainer container, IPackageRepository repository)
            : base(package, parent, container, AssetTypes.Package)
        {
            this.Name = package.Name;
            this.Model = package;

            foreach (var asset in repository.Assets.Where(x => x.PackageId == package.Id).OrderBy(x => x.Key))
            {
                this.AddChild(new AssetNodeViewModel(asset, parent, container));
            }  
        }
        public PackageTreeNodeViewModel(Object model, PackageDatabaseTreeViewModel parent, CompositionContainer container, String assetType)
        {
            this._parent = parent;
            this._contextMenuTopLevelItems = new ObservableCollection<MenuItemViewModel>();
            this._children = new ObservableCollection<PackageTreeNodeViewModel>();
            this.Model = model;

            var menuItemImports = container.GetExports<IMenuItem, IContextMenuItemMetaData>();
            var globalCommandImports = container.GetExports<IGlobalCommand>();

            var menuBuilder = new MenuBuilder(globalCommandImports);

            foreach (var import in menuItemImports.Where(x => x.Metadata.AssetType == assetType))
            {
                if (import.Metadata.IsPrimary)
                {
                    this.PrimaryCommand = import.Value.Command;
                }

                menuBuilder.AddItem(import.Value, import.Metadata);
            }

            foreach (var rootItem in menuBuilder.Build().Children)
            {
                MenuItemViewModel viewModel;

                if (rootItem is MenuSeparatorModel)
                {
                    viewModel = new MenuSeparatorViewModel();
                }
                else
                {
                    viewModel = new MenuItemViewModel(this.Model, rootItem.HeaderText, rootItem.Command, rootItem.GestureText, rootItem.Children);
                }

                _contextMenuTopLevelItems.Add(viewModel);
            }
        }