Esempio n. 1
0
        public DataSchema CompileSchema(IVerificationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            DataSchema dataSchema = new DataSchema();
            dataSchema.Name = Name;

            foreach (var filePath in InputFiles)
            {
                var inputFilePath = Path.GetFullPath(filePath);

                if (!File.Exists(inputFilePath))
                {

                    context.Add(new VerificationMessage(Severity.Error, string.Format(CultureInfo.CurrentCulture, Properties.Resources.InputFileNotFound, inputFilePath)));
                    return null;
                }

                using (StreamReader reader = new StreamReader(inputFilePath))
                {
                    dataSchema.LoadDataSchemaFile(reader, context);
                }
            }

            if (!string.IsNullOrEmpty(Options.PrimaryKeyFormatString))
            {
                dataSchema.NameFormats.PrimaryKeyFormatString = Options.PrimaryKeyFormatString;
            }
            if (!string.IsNullOrEmpty(Options.ForeignKeyFormatString))
            {
                dataSchema.NameFormats.ForeignKeyFormatString = Options.ForeignKeyFormatString;
            }
            if (!string.IsNullOrEmpty(Options.UniqueIndexFormatString))
            {
                dataSchema.NameFormats.UniqueIndexFormatString = Options.UniqueIndexFormatString;
            }
            if (!string.IsNullOrEmpty(Options.IndexFormatString))
            {
                dataSchema.NameFormats.IndexFormatString = Options.IndexFormatString;
            }

            return dataSchema;
        }
Esempio n. 2
0
        private DataSchema InitializeSchema()
        {
            var verificationContext = new VerificationContext();
            DataSchema dataSchema = new DataSchema();
            dataSchema.Name = Path.GetFileNameWithoutExtension(DataTypesFilePath);
            using (StreamReader reader = new StreamReader(DataTypesFilePath))
            {
                dataSchema.LoadDataSchemaFile(reader, verificationContext);
            }
            dataSchema.Verify(verificationContext);

            if (!backgroundWorker.CancellationPending && verificationContext.HasErrors)
            {
                ReportErrors(verificationContext);
                return null;
            }

            return dataSchema;
        }