コード例 #1
0
        protected override void OnExecute()
        {
            if (this.Culture != string.Empty)
            {
                System.Globalization.CultureInfo.DefaultThreadCurrentCulture   = new System.Globalization.CultureInfo(this.Culture);
                System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = new System.Globalization.CultureInfo(this.Culture);
            }

            this.Out.WriteLine("receiving info");
            var metaData = this.service.GetMetaData(this.Address, DataBaseSettings.DataBaseName, DataBaseSettings.Tags, FilterSettings.FilterExpression, CodeSettings.Devmode, this.Revision);

            metaData = ReplaceOptionProcessor.Process(metaData);

            var generationSettings = new CodeGenerationSettings()
            {
                ClassName     = CodeSettings.ClassName,
                Namespace     = CodeSettings.Namespace,
                BaseNamespace = CodeSettings.BaseNamespace,
                Prefix        = CodeSettings.Prefix,
                Postfix       = CodeSettings.Postfix,
                BasePath      = CodeSettings.BasePath,
                Options       = CodeSettings.Options,
                Tags          = (TagInfo)DataBaseSettings.Tags,
                Revision      = this.Revision,
            };

            foreach (var item in CommandStringUtility.ArgumentsToDictionary(this.Arguments))
            {
                generationSettings.Arguments.Add(item);
            }

            if (CodeSettings.IsBuildMode == true)
            {
                var compiler = this.compilers.FirstOrDefault(item => item.Name == CodeSettings.LanguageType);
                if (compiler == null)
                {
                    throw new InvalidOperationException($"'{CodeSettings.LanguageType}'은(는) 존재하지 않는 언어입니다.");
                }
                this.Out.WriteLine("compiling code.");
                compiler.Compile(this.OutputPath, metaData.Item1, generationSettings, CodeSettings.BuildTarget);
                this.Out.WriteLine("code compiled.");
            }
            else
            {
                this.Out.WriteLine("code generating.");
                var generator = this.generators.FirstOrDefault(item => item.Name == CodeSettings.LanguageType);
                if (generator == null)
                {
                    throw new InvalidOperationException($"'{CodeSettings.LanguageType}'은(는) 존재하지 않는 언어입니다.");
                }
                generator.Generate(this.OutputPath, metaData.Item1, generationSettings);
                this.Out.WriteLine("code generated.");
            }

            this.Out.WriteLine("data serializing.");
            var serializer = this.serializers.FirstOrDefault(item => item.Name == this.DataType);

            serializer.Serialize(Path.Combine(this.OutputPath, this.DataFilename), metaData.Item2);
            this.Out.WriteLine("data serialized.");
        }
コード例 #2
0
ファイル: GetDataCommand.cs プロジェクト: teize001/Crema
        private void SerializeAll(SerializationSet metaData)
        {
            var serializer       = this.GetDataSerializer(this.OutputType);
            var filteredMetaData = ReplaceOptionProcessor.Process(metaData);

            serializer.Serialize(this.Filename, filteredMetaData);
        }
コード例 #3
0
        private void GenerateCode()
        {
            var generator = this.generators.FirstOrDefault(item => item.Name == CodeSettings.LanguageType);

            if (generator == null)
            {
                throw new InvalidOperationException($"'{CodeSettings.LanguageType}'은(는) 존재하지 않는 언어입니다.");
            }

            this.Out.WriteLine("receiving info");
            var metaData = this.service.GetMetaData(this.Address, DataBaseSettings.DataBaseName, DataBaseSettings.Tags, FilterSettings.FilterExpression, CodeSettings.Devmode, this.Revision);

            metaData = ReplaceOptionProcessor.Process(metaData);

            var generationSettings = new CodeGenerationSettings()
            {
                ClassName     = CodeSettings.ClassName,
                Namespace     = CodeSettings.Namespace,
                BaseNamespace = CodeSettings.BaseNamespace,
                Prefix        = CodeSettings.Prefix,
                Postfix       = CodeSettings.Postfix,
                BasePath      = CodeSettings.BasePath,
                Options       = CodeSettings.Options,
                Tags          = (TagInfo)DataBaseSettings.Tags,
                Revision      = this.Revision,
            };

            this.Out.WriteLine("generating code.");
            generator.Generate(this.OutputPath, metaData.Item1, generationSettings);
            this.Out.WriteLine("code generated.");
        }
コード例 #4
0
ファイル: GetDataCommand.cs プロジェクト: teize001/Crema
        protected override void OnExecute()
        {
            if (this.Culture != string.Empty)
            {
                System.Globalization.CultureInfo.DefaultThreadCurrentCulture   = new System.Globalization.CultureInfo(this.Culture);
                System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = new System.Globalization.CultureInfo(this.Culture);
            }

            this.Out.WriteLine("receiving info");
            var metaData = service.GetDataGenerationData(this.Address, DataBaseSettings.DataBaseName, DataBaseSettings.Tags, FilterSettings.FilterExpression, this.Devmode, this.Revision);

            metaData = ReplaceOptionProcessor.Process(metaData);

            this.Out.WriteLine("data serializing.");
            this.Serialize(metaData);
            this.Out.WriteLine("data serialized.");
        }
コード例 #5
0
ファイル: GetDataCommand.cs プロジェクト: teize001/Crema
        private void SerializePerTable(SerializationSet metaData)
        {
            var filteredMetaDataList = new List <SerializationSet>();

            foreach (var table in metaData.Tables)
            {
                var filteredMetaData = metaData.Filter(table.Name);
                filteredMetaData = ReplaceOptionProcessor.Process(filteredMetaData);

                if (filteredMetaData.Tables.Any())
                {
                    filteredMetaDataList.Add(filteredMetaData);
                }
            }

            foreach (var dataSet in filteredMetaDataList)
            {
                var filepath   = Path.Combine(this.Filename, $"{dataSet.Tables[0].Name}.{DataSplitSetting.Ext}");
                var serializer = this.GetDataSerializer(this.OutputType);
                serializer.Serialize(filepath, dataSet);
            }
        }