Exemplo n.º 1
0
        private Dictionary <string, Type> GetArgumentTypes()
        {
            var properties = new Dictionary <string, Type>(this.Arguments.Length);

            foreach (var item in this.Arguments)
            {
                if (CommandStringUtility.TryGetKeyValue(item, out var key, out var value) == true)
                {
                    var typeName = value;
                    if (CommandStringUtility.IsWrappedOfQuote(value))
                    {
                        value = CommandStringUtility.TrimQuot(value);
                    }

                    if (value == "number")
                    {
                        properties.Add(key, typeof(decimal));
                    }
                    else if (value == "boolean")
                    {
                        properties.Add(key, typeof(bool));
                    }
                    else if (value == "string")
                    {
                        properties.Add(key, typeof(string));
                    }
                    else
                    {
                        throw new ArgumentException(typeName);
                    }
                }
Exemplo n.º 2
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.");
        }
Exemplo n.º 3
0
 private bool ParseCommandLine()
 {
     try
     {
         if (this.FindResource("bootstrapper") is AppBootstrapper bootstrapper)
         {
             var sb     = new StringBuilder();
             var parser = new CommandLineParser(bootstrapper.Settings)
             {
                 Out = new StringWriter(sb)
             };
             var(name, arguments) = CommandStringUtility.SplitCommandLine(Environment.CommandLine);
             if (parser.TryParseCommandLine(Environment.CommandLine) == false && arguments.Any() == false)
             {
                 MessageBox.Show(sb.ToString(), "Usage", MessageBoxButton.OK, MessageBoxImage.Information);
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return(false);
     }
     return(true);
 }
        public void Test3()
        {
            var parser = new CommandLineParser(this);

            parser.Parse("get \"database=\\\"a b c\\\"\"");

            CommandStringUtility.ArgumentsToDictionary(this.Arguments);
        }
Exemplo n.º 5
0
 private IDictionary <string, object> GetProperties()
 {
     return(CommandStringUtility.ArgumentsToDictionary(this.Arguments));
 }