Пример #1
0
        /// <summary>
        ///     The load data.
        /// </summary>
        private void LoadData()
        {
            if (!string.IsNullOrEmpty(this.ModelPath) && !string.IsNullOrEmpty(this.ConfigPath))
            {
                FilePersistenceOptions options = new FilePersistenceOptions {
                    Path = this.ModelPath
                };

                this.applicationService =
                    new ProjectDefinitionApplicationServiceFile {
                    FilePersistenceOptions = options
                };
                this.applicationService.Load();
                this.applicationService.ProjectDefinition.ModelPath = options.Path;
                this.applicationService.ProjectDefinition.Version   = 1;

                FilePersistenceOptions configOptions = new FilePersistenceOptions {
                    Path = this.ConfigPath
                };
                this.applicationConfiguration =
                    new ConfigurationApplicationServiceFile {
                    FilePersistenceOptions = configOptions
                };

                this.applicationConfiguration.Load();

                this.TemplateManagementUserControl1.DataSource =
                    this.applicationConfiguration.ApplicationSettings.Templates[0];
                this.ManagePackageUserControl1.DataSource =
                    this.applicationConfiguration.ApplicationSettings.Packages[0];

                if (this.applicationConfiguration.ApplicationSettings.Templates.Count > 0)
                {
                    this.ManagePackageUserControl1.Templates =
                        this.applicationConfiguration.ApplicationSettings.Templates;
                }

                this.ProjectDetailsUserControl1.Project              = this.applicationService.ProjectDefinition;
                this.ProjectDomainUserControl1.SelectedIndexChanged +=
                    this.ProjectDomainUserControl1_SelectedIndexChanged;
                this.ProjectDomainUserControl1.ApplicationService = this.applicationService;
                this.projectDomainDetailsUserControl1.Packages    =
                    this.applicationConfiguration.ApplicationSettings.Packages;
                this.projectDomainDetailsUserControl1.ApplicationService = this.applicationService;
                this.tabControl1.Enabled = true;
                this.BtnSave.Enabled     = true;
                this.LblPath.Text        = this.ModelPath;
            }
            else
            {
                this.tabControl1.Enabled = false;
                this.BtnSave.Enabled     = false;
                this.LblPath.Text        = "No Model File Loaded";
            }
        }
        /// <summary>
        /// Create test values.
        /// </summary>
        /// <param name="applicationService">
        /// The application Service.
        /// </param>
        protected void CreateTestValues(IConfigurationApplicationService applicationService)
        {
            List <DataType> dataTypes = new List <DataType>();

            dataTypes.Add(new DataType {
                Id = Guid.NewGuid(), Name = "Context"
            });
            dataTypes.Add(new DataType {
                Id = Guid.NewGuid(), Name = "Entity"
            });
            dataTypes.Add(new DataType {
                Id = Guid.NewGuid(), Name = "Repository"
            });
            dataTypes.Add(new DataType {
                Id = Guid.NewGuid(), Name = "Application Service"
            });
            dataTypes.Add(new DataType {
                Id = Guid.NewGuid(), Name = "ViewModel"
            });
            applicationService.ApplicationSettings.DataTypes = dataTypes;

            ScaffoldConfig.Load();

            Template template = new Template
            {
                ConfigLocation   = ConfigLocation.Data,
                DataType         = Guid.Empty,
                Id               = Guid.NewGuid(),
                Name             = "Template",
                Version          = 1,
                TemplatePath     = "Test.t4",
                LanguageOutputId =
                    new Guid(
                        ScaffoldConfig.LanguageOutputs[0].Metadata["ValueMetaData"]
                        .ToString()),
                GeneratorTypeId = new Guid(
                    ScaffoldConfig.OutputGenerators[0].Metadata["ValueMetaData"]
                    .ToString())
            };

            applicationService.ApplicationSettings.Templates.Add(template);
        }
Пример #3
0
 /// <summary>
 /// The test project definition.
 /// </summary>
 /// <param name="applicationService">
 /// The application service.
 /// </param>
 protected void TestProjectDefinition(IConfigurationApplicationService applicationService)
 {
     Assert.IsNotNull(applicationService.ApplicationSettings.DataTypes, "DataTypes should not be empty");
     Assert.AreEqual(5, applicationService.ApplicationSettings.DataTypes.Count, "There should be 5 DataTypes");
 }
Пример #4
0
        public void LoadProjects()
        {
            try
            {
                if (!string.IsNullOrEmpty(ModelPath) && !string.IsNullOrEmpty(ConfigPath))
                {
                    FilePersistenceOptions options = new FilePersistenceOptions {
                        Path = ModelPath
                    };

                    projectApplicationService =
                        new ProjectDefinitionApplicationServiceFile {
                        FilePersistenceOptions = options
                    };
                    projectApplicationService.Load();
                    projectApplicationService.ProjectDefinition.ModelPath = options.Path;
                    projectApplicationService.ProjectDefinition.Version   = 1;

                    FilePersistenceOptions configOptions = new FilePersistenceOptions {
                        Path = ConfigPath
                    };
                    applicationConfiguration =
                        new ConfigurationApplicationServiceFile {
                        FilePersistenceOptions = configOptions
                    };

                    applicationConfiguration.Load();

                    TemplateManagementUserControl.DataSource =
                        applicationConfiguration.ApplicationSettings.Templates[0];

                    if (projectApplicationService.ProjectDefinition.Domains.Count > 0)
                    {
                        // By default use the first domain
                        PackageUserControl.SelectedPackage =
                            projectApplicationService.ProjectDefinition.Domains[0].Package;
                        PackageUserControl.DataSource =
                            applicationConfiguration.ApplicationSettings.Packages[0];
                        PackageUserControl.DomainDefinition =
                            projectApplicationService.ProjectDefinition.Domains[0];
                    }

                    if (applicationConfiguration.ApplicationSettings.Templates.Count > 0)
                    {
                        PackageUserControl.Templates =
                            applicationConfiguration.ApplicationSettings.Templates;
                    }

                    TemplateManagementUserControl.ProjectDefinition = projectApplicationService.ProjectDefinition;
                    TemplateManagementUserControl.Packages          = applicationConfiguration.ApplicationSettings
                                                                      .Packages[0].ReturnPackageItems();

                    ProjectDetailsUserControl1.Project              = projectApplicationService.ProjectDefinition;
                    ProjectDomainUserControl1.SelectedIndexChanged +=
                        ProjectDomainUserControl1_SelectedIndexChanged;
                    ProjectDomainUserControl1.ApplicationService = projectApplicationService;
                    projectDomainDetailsUserControl1.Packages    =
                        applicationConfiguration.ApplicationSettings.Packages;
                    projectDomainDetailsUserControl1.ApplicationService       = projectApplicationService;
                    projectDomainDetailsUserControl1.ProjectDomainUserControl = ProjectDomainUserControl1;

                    TabControl.Enabled = true;
                    BtnSave.Enabled    = true;
                    LabelPath.Text     = ModelPath;
                }
                else
                {
                    TabControl.Enabled = false;
                    BtnSave.Enabled    = false;
                    LabelPath.Text     = "No Model File Loading";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Loading", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TabControl.Enabled = false;
                BtnSave.Enabled    = false;
                LabelPath.Text     = "Model file does not exist!";
            }
        }
Пример #5
0
 public ConfigurationController(IConfigurationApplicationService configurationApplicationService)
 {
     _configurationApplicationService = configurationApplicationService;
 }