internal static async Task <ModelTypeAndContextModel> ValidateModelAndGetEFMetadata(
            CommonCommandLineModel commandLineModel,
            IEntityFrameworkService entityFrameworkService,
            IModelTypesLocator modelTypesLocator,
            string areaName)
        {
            ModelType model       = ValidationUtil.ValidateType(commandLineModel.ModelClass, "model", modelTypesLocator);
            ModelType dataContext = ValidationUtil.ValidateType(commandLineModel.DataContextClass, "dataContext", modelTypesLocator, throwWhenNotFound: false);

            // Validation successful
            Contract.Assert(model != null, MessageStrings.ValidationSuccessfull_modelUnset);

            var dbContextFullName = dataContext != null ? dataContext.FullName : commandLineModel.DataContextClass;

            var modelMetadata = await entityFrameworkService.GetModelMetadata(
                dbContextFullName,
                model,
                areaName,
                commandLineModel.UseSqlite);

            return(new ModelTypeAndContextModel()
            {
                ModelType = model,
                DbContextFullName = dbContextFullName,
                ContextProcessingResult = modelMetadata,
                UseSqlite = commandLineModel.UseSqlite
            });
        }
Exemple #2
0
 protected CommonCommandLineModel(CommonCommandLineModel copyFrom)
 {
     ModelClass               = copyFrom.ModelClass;
     DataContextClass         = copyFrom.DataContextClass;
     ReferenceScriptLibraries = copyFrom.ReferenceScriptLibraries;
     LayoutPage               = copyFrom.LayoutPage;
     UseDefaultLayout         = copyFrom.UseDefaultLayout;
     Force = copyFrom.Force;
     RelativeFolderPath  = copyFrom.RelativeFolderPath;
     ControllerNamespace = copyFrom.ControllerNamespace;
 }
        internal static async Task <ModelTypeAndContextModel> ValidateModelAndGetCodeModelMetadata(
            CommonCommandLineModel commandLineModel,
            ICodeModelService codeModeService,
            IModelTypesLocator modelTypesLocator)
        {
            ModelType model = ValidationUtil.ValidateType(commandLineModel.ModelClass, "model", modelTypesLocator);

            Contract.Assert(model != null, MessageStrings.ValidationSuccessfull_modelUnset);
            var result = await codeModeService.GetModelMetadata(model);

            return(new ModelTypeAndContextModel()
            {
                ModelType = model,
                ContextProcessingResult = result
            });
        }
        protected string ValidateAndGetOutputPath(CommonCommandLineModel commandLineModel, string outputFileName)
        {
            string outputFolder = String.IsNullOrEmpty(commandLineModel.RelativeFolderPath)
                ? ApplicationInfo.ApplicationBasePath
                : Path.Combine(ApplicationInfo.ApplicationBasePath, commandLineModel.RelativeFolderPath);

            var outputPath = Path.Combine(outputFolder, outputFileName);

            if (File.Exists(outputPath) && !commandLineModel.Force)
            {
                throw new InvalidOperationException(string.Format(
                                                        CultureInfo.CurrentCulture,
                                                        MessageStrings.FileExists_useforce,
                                                        outputPath));
            }

            return(outputPath);
        }