public static CodeGenerationLanguage GetLanguage(this CodeGenerationElement @this)
        {
            if (@this.Language.HasValue)
            {
                return(@this.Language.Value);
            }

            string language = Arguments.GetArgument("language", "l");

            if (!string.IsNullOrEmpty(language))
            {
                switch (language.ToLower())
                {
                case "c#":
                case "cs":
                case "csharp":
                    return(CodeGenerationLanguage.CSharp);

                case "vb":
                case "visualbasic":
                    return(CodeGenerationLanguage.VisualBasic);

                case "f#":
                case "fs":
                case "fsharp":
                    return(CodeGenerationLanguage.FSharp);

                case "ts":
                case "typescript":
                    return(CodeGenerationLanguage.TypeScript);
                }
            }

            return(CodeGenerationLanguage.CSharp);
        }
        public static CodeGenerationFileOptionsElement GetOutputOptions(this CodeGenerationElement @this, CodeGenerationFileType fileType)
        {
            var options = @this.Files.FirstOrDefault(f => f.FileType == fileType && !string.IsNullOrEmpty(f.Filename));
            var path    = GetOutputPath(@this);

            return(options ?? new CodeGenerationFileOptionsElement()
            {
                FileType = fileType, Filename = GetOutputFile(@this), Strategy = CodeGenerationFileStrategy.SingleFile
            });
        }
        public static string GetOutputFile(this CodeGenerationElement @this)
        {
            string output = GetOutputPath(@this);

            if (string.IsNullOrEmpty(output))
            {
                return("Xrm.cs");
            }
            else
            {
                return(Path.GetFileName(output));
            }
        }
        public static string GetOutputPath(this CodeGenerationElement @this)
        {
            string output = Arguments.GetArgument("out", "o");
            string path   = @this.Path;

            if (string.IsNullOrEmpty(output))
            {
                if (string.IsNullOrEmpty(path))
                {
                    return(Environment.CurrentDirectory);
                }
                else
                {
                    if (Path.IsPathRooted(path))
                    {
                        return(Path.GetFullPath(path));
                    }
                    else
                    {
                        return(Path.Combine(Environment.CurrentDirectory, path));
                    }
                }
            }
            else
            {
                if (string.IsNullOrEmpty(path))
                {
                    return(Path.Combine(Environment.CurrentDirectory, output));
                }
                else
                {
                    var combinedPath = Path.Combine(path, output);

                    if (Path.IsPathRooted(combinedPath))
                    {
                        return(combinedPath);
                    }
                    else
                    {
                        return(Path.Combine(Environment.CurrentDirectory, combinedPath));
                    }
                }
            }
        }