Example #1
0
        private void AddNewService(object param)
        {
            if (ModelType == null)
            {
                DisplayErrorMessage(DialogHost, "新增服务接口前需要指定模型。");
                return;
            }

            CreateServicetDialog dialog = new CreateServicetDialog();

            Model.ServiceTypeName = Model.GenerateDefaultServiceTypeName();

            ControllerWithEntityViewModelViewModel viewModel = new ControllerWithEntityViewModelViewModel(Model);

            dialog.DataContext = viewModel;

            if (dialog.ShowModal() == true)
            {
                ServiceType     = AddNewService(viewModel.ServiceTypeName);
                ServiceTypeName = ServiceType.DisplayName;
            }
            else
            {
                ServiceType     = null;
                ServiceTypeName = null;
            }
        }
Example #2
0
        private void AddNewViewModel(object param)
        {
            if (ModelType == null)
            {
                DisplayErrorMessage(DialogHost, "新增视图模型前需要指定模型。");
                return;
            }

            CreateViewModelDialog dialog = new CreateViewModelDialog();

            Model.ViewModelTypeName = Model.GenerateDefaultViewModelTypeName();
            List <ViewModelProperty> viewModelPropertys = new List <ViewModelProperty>();

            foreach (CodeElement codeElement in Model.ModelType.CodeType.Children)
            {
                if (codeElement.Kind == vsCMElement.vsCMElementProperty)
                {
                    CodeProperty property = codeElement as CodeProperty;
                    viewModelPropertys.Add(new ViewModelProperty
                    {
                        EntityPropertyName    = property.Name,
                        ViewModelPropertyName = property.Name,
                        PropertyType          = property.Type.AsString
                    });
                }
            }
            Model.ViewModelPropertys = viewModelPropertys;
            ControllerWithEntityViewModelViewModel viewModel = new ControllerWithEntityViewModelViewModel(Model);

            dialog.DataContext = viewModel;

            if (dialog.ShowModal() == true)
            {
                ViewModelType     = AddNewViewModel(viewModel.ViewModelTypeName);
                ViewModelTypeName = ViewModelType.DisplayName;
            }
            else
            {
                ViewModelType            = null;
                ViewModelTypeName        = null;
                Model.ViewModelPropertys = null;
            }
        }