GetInitialCompilerArgs() public method

public GetInitialCompilerArgs ( LanguagesEnum language ) : string
language LanguagesEnum
return string
コード例 #1
0
        public ActionResult Index(RundotnetData data, string savedNr = null, string lang_title = null)
        {
            Compression.SetCompression();

            //retrieve saved code
            savedNr = savedNr ?? HttpContext.Request.QueryString["code"];
            if (!string.IsNullOrEmpty(savedNr))
            {
                var code = Model.GetCode(savedNr, false);
                if (code == null)
                {
                    throw new HttpException(404, "not found");
                }
                data.Title          = code.Title;
                data.Program        = code.Program;
                data.Input          = code.Input;
                data.CompilerArgs   = code.CompilerArgs;
                data.Output         = code.Output;
                data.LanguageChoice = (LanguagesEnum)code.Lang;
                data.EditorChoice   = (EditorsEnum)code.Editor;
                data.WholeError     = code.WholeError;
                data.WholeWarning   = code.Warnings;
                data.ShowWarnings   = code.ShowWarnings;
                data.RunStats       = code.Stats;
                data.CodeGuid       = code.Guid;
                data.Votes          = code.Votes;
                data.User_Id        = code.UserId;

                data.IsInEditMode      = false;
                data.EditVisible       = code.IsPrimaryVersion;
                data.BackToForkVisible = false;
                data.PrimaryGuid       = code.PrimaryGuid == null ? data.CodeGuid : code.PrimaryGuid;
                data.IsSaved           = true;
                if (data.PrimaryGuid != data.CodeGuid)
                {
                    data.LivesVersion = Model.IsLive(data.PrimaryGuid);
                }

                if (SessionManager.IsDarkTheme)
                {
                    data.EditorChoice = EditorsEnum.Codemirror;
                }
                if (Utils.Utils.IsMobile)
                {
                    data.EditorChoice = EditorsEnum.Simple;
                }
                return(View(data));
            }

            data.IsLive       = false;
            data.IsInEditMode = false;

            if (!string.IsNullOrEmpty(lang_title))
            {
                if (lang_title.ToLower() == "nasm_online_compiler" || lang_title.ToLower() == "nasm")
                {
                    data.LanguageChoice = LanguagesEnum.Nasm;
                }
                else if (lang_title.ToLower() == "csharp_online_compiler" || lang_title.ToLower() == "csharp")
                {
                    data.LanguageChoice = LanguagesEnum.CSharp;
                }
                else if (lang_title.ToLower() == "cpp_online_compiler_gcc" || lang_title.ToLower() == "gcc")
                {
                    data.LanguageChoice = LanguagesEnum.CPP;
                }
                else if (lang_title.ToLower() == "cpp_online_compiler_clang" || lang_title.ToLower() == "clang")
                {
                    data.LanguageChoice = LanguagesEnum.CPPClang;
                }
                else if (lang_title.ToLower() == "cpp_online_compiler_visual" || lang_title.ToLower() == "vcpp")
                {
                    data.LanguageChoice = LanguagesEnum.VCPP;
                }
                else if (lang_title.ToLower() == "c_online_compiler_gcc" || lang_title.ToLower() == "c_gcc")
                {
                    data.LanguageChoice = LanguagesEnum.C;
                }
                else if (lang_title.ToLower() == "c_online_compiler_clang" || lang_title.ToLower() == "c_clang")
                {
                    data.LanguageChoice = LanguagesEnum.CClang;
                }
                else if (lang_title.ToLower() == "c_online_compiler_visual" || lang_title.ToLower() == "c_vcpp")
                {
                    data.LanguageChoice = LanguagesEnum.VC;
                }
                else if (lang_title.ToLower() == "common_lisp_online_compiler" || lang_title.ToLower() == "clisp")
                {
                    data.LanguageChoice = LanguagesEnum.Lisp;
                }
                else if (lang_title.ToLower() == "d_online_compiler" || lang_title.ToLower() == "d")
                {
                    data.LanguageChoice = LanguagesEnum.D;
                }
                else if (lang_title.ToLower() == "fsharp_online_compiler" || lang_title.ToLower() == "fsharp")
                {
                    data.LanguageChoice = LanguagesEnum.FSharp;
                }
                else if (lang_title.ToLower() == "go_online_compiler" || lang_title.ToLower() == "go")
                {
                    data.LanguageChoice = LanguagesEnum.Go;
                }
                else if (lang_title.ToLower() == "haskell_online_compiler" || lang_title.ToLower() == "haskell")
                {
                    data.LanguageChoice = LanguagesEnum.Haskell;
                }
                else if (lang_title.ToLower() == "java_online_compiler" || lang_title.ToLower() == "java")
                {
                    data.LanguageChoice = LanguagesEnum.Java;
                }
                else if (lang_title.ToLower() == "js_online_compiler" || lang_title.ToLower() == "js")
                {
                    data.LanguageChoice = LanguagesEnum.Javascript;
                }
                else if (lang_title.ToLower() == "lua_online_compiler" || lang_title.ToLower() == "lua")
                {
                    data.LanguageChoice = LanguagesEnum.Lua;
                }
                else if (lang_title.ToLower() == "nodejs_online_compiler" || lang_title.ToLower() == "nodejs")
                {
                    data.LanguageChoice = LanguagesEnum.Nodejs;
                }
                else if (lang_title.ToLower() == "octave_online_compiler" || lang_title.ToLower() == "octave")
                {
                    data.LanguageChoice = LanguagesEnum.Octave;
                }
                else if (lang_title.ToLower() == "objectivec_online_compiler" || lang_title.ToLower() == "objectivec")
                {
                    data.LanguageChoice = LanguagesEnum.ObjectiveC;
                }
                else if (lang_title.ToLower() == "pascal_online_compiler" || lang_title.ToLower() == "pascal")
                {
                    data.LanguageChoice = LanguagesEnum.Pascal;
                }
                else if (lang_title.ToLower() == "perl_online_compiler" || lang_title.ToLower() == "perl")
                {
                    data.LanguageChoice = LanguagesEnum.Perl;
                }
                else if (lang_title.ToLower() == "php_online_compiler" || lang_title.ToLower() == "php")
                {
                    data.LanguageChoice = LanguagesEnum.Php;
                }
                else if (lang_title.ToLower() == "prolog_online_compiler" || lang_title.ToLower() == "prolog")
                {
                    data.LanguageChoice = LanguagesEnum.Prolog;
                }
                else if (lang_title.ToLower() == "python_online_compiler" || lang_title.ToLower() == "python")
                {
                    data.LanguageChoice = LanguagesEnum.Python;
                }
                else if (lang_title.ToLower() == "python3_online_compiler" || lang_title.ToLower() == "python3")
                {
                    data.LanguageChoice = LanguagesEnum.Python3;
                }
                else if (lang_title.ToLower() == "r_online_compiler" || lang_title.ToLower() == "r")
                {
                    data.LanguageChoice = LanguagesEnum.R;
                }
                else if (lang_title.ToLower() == "ruby_online_compiler" || lang_title.ToLower() == "ruby")
                {
                    data.LanguageChoice = LanguagesEnum.Ruby;
                }
                else if (lang_title.ToLower() == "scala_online_compiler" || lang_title.ToLower() == "scala")
                {
                    data.LanguageChoice = LanguagesEnum.Scala;
                }
                else if (lang_title.ToLower() == "scheme_online_compiler" || lang_title.ToLower() == "scheme")
                {
                    data.LanguageChoice = LanguagesEnum.Scheme;
                }
                else if (lang_title.ToLower() == "sql_server_online_compiler" || lang_title.ToLower() == "sql_server")
                {
                    data.LanguageChoice = LanguagesEnum.SqlServer;
                }
                else if (lang_title.ToLower() == "mysql_online_compiler" || lang_title.ToLower() == "mysql")
                {
                    data.LanguageChoice = LanguagesEnum.MySql;
                }
                else if (lang_title.ToLower() == "oracle_online_compiler" || lang_title.ToLower() == "oracle")
                {
                    data.LanguageChoice = LanguagesEnum.Oracle;
                }
                else if (lang_title.ToLower() == "postgresql_online_compiler" || lang_title.ToLower() == "postgresql")
                {
                    data.LanguageChoice = LanguagesEnum.Postgresql;
                }
                else if (lang_title.ToLower() == "tcl_online_compiler" || lang_title.ToLower() == "tcl")
                {
                    data.LanguageChoice = LanguagesEnum.Tcl;
                }
                else if (lang_title.ToLower() == "visual_basic_online_compiler" || lang_title.ToLower() == "vb")
                {
                    data.LanguageChoice = LanguagesEnum.VB;
                }
                else if (lang_title.ToLower() == "client_side" || lang_title.ToLower() == "jsfiddle")
                {
                    data.LanguageChoice = LanguagesEnum.ClientSide;
                }
                else if (lang_title.ToLower() == "swift_online_compiler" || lang_title.ToLower() == "swift")
                {
                    data.LanguageChoice = LanguagesEnum.Swift;
                }
                else if (lang_title.ToLower() == "bash_online_compiler" || lang_title.ToLower() == "bash")
                {
                    data.LanguageChoice = LanguagesEnum.Bash;
                }
                else if (lang_title.ToLower() == "ada_online_compiler" || lang_title.ToLower() == "ada")
                {
                    data.LanguageChoice = LanguagesEnum.Ada;
                }
                else if (lang_title.ToLower() == "erlang_online_compiler" || lang_title.ToLower() == "erlang")
                {
                    data.LanguageChoice = LanguagesEnum.Erlang;
                }
                else if (lang_title.ToLower() == "elixir_online_compiler" || lang_title.ToLower() == "elixir")
                {
                    data.LanguageChoice = LanguagesEnum.Elixir;
                }
                else if (lang_title.ToLower() == "ocaml_online_compiler" || lang_title.ToLower() == "ocaml")
                {
                    data.LanguageChoice = LanguagesEnum.Ocaml;
                }
                else
                {
                    data.LanguageChoice = LanguagesEnum.CSharp;
                }
            }

            if ((int)data.LanguageChoice != (int)LanguagesEnum.Unknown && (int)data.EditorChoice != (int)EditorsEnum.Unknown && !Utils.Utils.IsMobile)
            {
                Model.SaveUserProfile(data.LanguageChoice, data.EditorChoice);
            }

            UserProfile profile = null;

            if ((int)data.LanguageChoice == (int)LanguagesEnum.Unknown || (int)data.EditorChoice == (int)EditorsEnum.Unknown)
            {
                profile = Model.GetUserProfile();
            }

            if ((int)data.LanguageChoice == (int)LanguagesEnum.Unknown)
            {
                data.LanguageChoice = profile.LanguageChoice;
            }

            if ((int)data.EditorChoice == (int)EditorsEnum.Unknown)
            {
                data.EditorChoice = profile.EditorChoice;
            }

            data.Program      = data.GetInitialCode(data.LanguageChoice, data.EditorChoice);
            data.CompilerArgs = data.GetInitialCompilerArgs(data.LanguageChoice);

            if (SessionManager.IsDarkTheme)
            {
                data.EditorChoice = EditorsEnum.Codemirror;
            }
            if (Utils.Utils.IsMobile)
            {
                data.EditorChoice = EditorsEnum.Simple;
            }

            return(View(data));
        }
コード例 #2
0
        public ActionResult Index(RundotnetData data, string savedNr = null, string lang_title = null)
        {
            Compression.SetCompression();

            //retrieve saved code
            savedNr = savedNr ?? HttpContext.Request.QueryString["code"];
            if (!string.IsNullOrEmpty(savedNr))
            {
                var code = Model.GetCode(savedNr, false);
                if (code == null)
                {
                    throw new HttpException(404, "not found");
                }
                data.Title = code.Title;
                data.Program = code.Program;
                data.Input = code.Input;
                data.CompilerArgs = code.CompilerArgs;
                data.Output = code.Output;
                data.LanguageChoice = (LanguagesEnum)code.Lang;
                data.EditorChoice = (EditorsEnum)code.Editor;
                data.WholeError = code.WholeError;
                data.WholeWarning = code.Warnings;
                data.ShowWarnings = code.ShowWarnings;
                data.RunStats = code.Stats;
                data.CodeGuid = code.Guid;
                data.Votes = code.Votes;
                data.User_Id = code.UserId;

                data.IsInEditMode = false;
                data.EditVisible = code.IsPrimaryVersion;
                data.BackToForkVisible = false;
                data.PrimaryGuid = code.PrimaryGuid == null ? data.CodeGuid : code.PrimaryGuid;
                data.IsSaved = true;
                if (data.PrimaryGuid != data.CodeGuid)
                {
                    data.LivesVersion = Model.IsLive(data.PrimaryGuid);
                }

                if(Utils.Utils.IsMobile)
                {
                    data.EditorChoice = EditorsEnum.Simple;
                }
                return View(data);
            }

            data.IsLive = false;
            data.IsInEditMode = false;

            if (!string.IsNullOrEmpty(lang_title))
            {
                if (lang_title.ToLower() == "nasm_online_compiler" || lang_title.ToLower() == "nasm")
                {
                    data.LanguageChoice = LanguagesEnum.Nasm;
                }
                else if (lang_title.ToLower() == "csharp_online_compiler" || lang_title.ToLower() == "csharp")
                {
                    data.LanguageChoice = LanguagesEnum.CSharp;
                }
                else if (lang_title.ToLower() == "cpp_online_compiler_gcc" || lang_title.ToLower() == "gcc")
                {
                    data.LanguageChoice = LanguagesEnum.CPP;
                }
                else if (lang_title.ToLower() == "cpp_online_compiler_clang" || lang_title.ToLower() == "clang")
                {
                    data.LanguageChoice = LanguagesEnum.CPPClang;
                }
                else if (lang_title.ToLower() == "cpp_online_compiler_visual" || lang_title.ToLower() == "vcpp")
                {
                    data.LanguageChoice = LanguagesEnum.VCPP;
                }
                else if (lang_title.ToLower() == "c_online_compiler_gcc" || lang_title.ToLower() == "c_gcc")
                {
                    data.LanguageChoice = LanguagesEnum.C;
                }
                else if (lang_title.ToLower() == "c_online_compiler_clang" || lang_title.ToLower() == "c_clang")
                {
                    data.LanguageChoice = LanguagesEnum.CClang;
                }
                else if (lang_title.ToLower() == "c_online_compiler_visual" || lang_title.ToLower() == "c_vcpp")
                {
                    data.LanguageChoice = LanguagesEnum.VC;
                }
                else if (lang_title.ToLower() == "common_lisp_online_compiler" || lang_title.ToLower() == "clisp")
                {
                    data.LanguageChoice = LanguagesEnum.Lisp;
                }
                else if (lang_title.ToLower() == "d_online_compiler" || lang_title.ToLower() == "d")
                {
                    data.LanguageChoice = LanguagesEnum.D;
                }
                else if (lang_title.ToLower() == "fsharp_online_compiler" || lang_title.ToLower() == "fsharp")
                {
                    data.LanguageChoice = LanguagesEnum.FSharp;
                }
                else if (lang_title.ToLower() == "go_online_compiler" || lang_title.ToLower() == "go")
                {
                    data.LanguageChoice = LanguagesEnum.Go;
                }
                else if (lang_title.ToLower() == "haskell_online_compiler" || lang_title.ToLower() == "haskell")
                {
                    data.LanguageChoice = LanguagesEnum.Haskell;
                }
                else if (lang_title.ToLower() == "java_online_compiler" || lang_title.ToLower() == "java")
                {
                    data.LanguageChoice = LanguagesEnum.Java;
                }
                else if (lang_title.ToLower() == "js_online_compiler" || lang_title.ToLower() == "js")
                {
                    data.LanguageChoice = LanguagesEnum.Javascript;
                }
                else if (lang_title.ToLower() == "lua_online_compiler" || lang_title.ToLower() == "lua")
                {
                    data.LanguageChoice = LanguagesEnum.Lua;
                }
                else if (lang_title.ToLower() == "nodejs_online_compiler" || lang_title.ToLower() == "nodejs")
                {
                    data.LanguageChoice = LanguagesEnum.Nodejs;
                }
                else if (lang_title.ToLower() == "octave_online_compiler" || lang_title.ToLower() == "octave")
                {
                    data.LanguageChoice = LanguagesEnum.Octave;
                }
                else if (lang_title.ToLower() == "objectivec_online_compiler" || lang_title.ToLower() == "objectivec")
                {
                    data.LanguageChoice = LanguagesEnum.ObjectiveC;
                }
                else if (lang_title.ToLower() == "pascal_online_compiler" || lang_title.ToLower() == "pascal")
                {
                    data.LanguageChoice = LanguagesEnum.Pascal;
                }
                else if (lang_title.ToLower() == "perl_online_compiler" || lang_title.ToLower() == "perl")
                {
                    data.LanguageChoice = LanguagesEnum.Perl;
                }
                else if (lang_title.ToLower() == "php_online_compiler" || lang_title.ToLower() == "php")
                {
                    data.LanguageChoice = LanguagesEnum.Php;
                }
                else if (lang_title.ToLower() == "prolog_online_compiler" || lang_title.ToLower() == "prolog")
                {
                    data.LanguageChoice = LanguagesEnum.Prolog;
                }
                else if (lang_title.ToLower() == "python_online_compiler" || lang_title.ToLower() == "python")
                {
                    data.LanguageChoice = LanguagesEnum.Python;
                }
                else if (lang_title.ToLower() == "python3_online_compiler" || lang_title.ToLower() == "python3")
                {
                    data.LanguageChoice = LanguagesEnum.Python3;
                }
                else if (lang_title.ToLower() == "r_online_compiler" || lang_title.ToLower() == "r")
                {
                    data.LanguageChoice = LanguagesEnum.R;
                }
                else if (lang_title.ToLower() == "ruby_online_compiler" || lang_title.ToLower() == "ruby")
                {
                    data.LanguageChoice = LanguagesEnum.Ruby;
                }
                else if (lang_title.ToLower() == "scala_online_compiler" || lang_title.ToLower() == "scala")
                {
                    data.LanguageChoice = LanguagesEnum.Scala;
                }
                else if (lang_title.ToLower() == "scheme_online_compiler" || lang_title.ToLower() == "scheme")
                {
                    data.LanguageChoice = LanguagesEnum.Scheme;
                }
                else if (lang_title.ToLower() == "sql_server_online_compiler" || lang_title.ToLower() == "sql_server")
                {
                    data.LanguageChoice = LanguagesEnum.SqlServer;
                }
                else if (lang_title.ToLower() == "mysql_online_compiler" || lang_title.ToLower() == "mysql")
                {
                    data.LanguageChoice = LanguagesEnum.MySql;
                }
                else if (lang_title.ToLower() == "oracle_online_compiler" || lang_title.ToLower() == "oracle")
                {
                    data.LanguageChoice = LanguagesEnum.Oracle;
                }
                else if (lang_title.ToLower() == "postgresql_online_compiler" || lang_title.ToLower() == "postgresql")
                {
                    data.LanguageChoice = LanguagesEnum.Postgresql;
                }
                else if (lang_title.ToLower() == "tcl_online_compiler" || lang_title.ToLower() == "tcl")
                {
                    data.LanguageChoice = LanguagesEnum.Tcl;
                }
                else if (lang_title.ToLower() == "visual_basic_online_compiler" || lang_title.ToLower() == "vb")
                {
                    data.LanguageChoice = LanguagesEnum.VB;
                }
                else if (lang_title.ToLower() == "client_side" || lang_title.ToLower() == "jsfiddle")
                {
                    data.LanguageChoice = LanguagesEnum.ClientSide;
                }
                else if (lang_title.ToLower() == "swift_online_compiler" || lang_title.ToLower() == "swift")
                {
                    data.LanguageChoice = LanguagesEnum.Swift;
                }
                else if (lang_title.ToLower() == "bash_online_compiler" || lang_title.ToLower() == "bash")
                {
                    data.LanguageChoice = LanguagesEnum.Bash;
                }
                else if (lang_title.ToLower() == "ada_online_compiler" || lang_title.ToLower() == "ada")
                {
                    data.LanguageChoice = LanguagesEnum.Ada;
                }
                else if (lang_title.ToLower() == "erlang_online_compiler" || lang_title.ToLower() == "erlang")
                {
                    data.LanguageChoice = LanguagesEnum.Erlang;
                }
                else if (lang_title.ToLower() == "elixir_online_compiler" || lang_title.ToLower() == "elixir")
                {
                    data.LanguageChoice = LanguagesEnum.Elixir;
                }
                else if (lang_title.ToLower() == "ocaml_online_compiler" || lang_title.ToLower() == "ocaml")
                {
                    data.LanguageChoice = LanguagesEnum.Ocaml;
                }
                else
                {
                    data.LanguageChoice = LanguagesEnum.CSharp;
                }
            }

            if ((int)data.LanguageChoice != (int)LanguagesEnum.Unknown && (int)data.EditorChoice != (int)EditorsEnum.Unknown)
                Model.SaveUserProfile(data.LanguageChoice, data.EditorChoice);

            UserProfile profile = null;
            if ((int)data.LanguageChoice == (int)LanguagesEnum.Unknown || (int)data.EditorChoice == (int)EditorsEnum.Unknown)
                profile = Model.GetUserProfile();

            if ((int)data.LanguageChoice == (int)LanguagesEnum.Unknown)
                data.LanguageChoice = profile.LanguageChoice;

            if ((int)data.EditorChoice == (int)EditorsEnum.Unknown)
                data.EditorChoice = profile.EditorChoice;

            data.Program = data.GetInitialCode(data.LanguageChoice, data.EditorChoice);
            data.CompilerArgs = data.GetInitialCompilerArgs(data.LanguageChoice);

            if (Utils.Utils.IsMobile)
            {
                data.EditorChoice = EditorsEnum.Simple;
            }

            return View(data);
        }
コード例 #3
0
        public ActionResult Index(RundotnetData data, string savedNr = null)
        {
            Compression.SetCompression();

            //retrieve saved code
            savedNr = savedNr ?? HttpContext.Request.QueryString["code"];
            if (!string.IsNullOrEmpty(savedNr))
            {
                var code = Model.GetCode(savedNr, false);
                if (code == null)
                {
                    throw new HttpException(404, "not found");
                }
                data.Title          = code.Title;
                data.Program        = code.Program;
                data.Input          = code.Input;
                data.CompilerArgs   = code.CompilerArgs;
                data.Output         = code.Output;
                data.LanguageChoice = (LanguagesEnum)code.Lang;
                data.EditorChoice   = (EditorsEnum)code.Editor;
                data.WholeError     = code.WholeError;
                data.WholeWarning   = code.Warnings;
                data.ShowWarnings   = code.ShowWarnings;
                data.RunStats       = code.Stats;
                data.CodeGuid       = code.Guid;
                data.Votes          = code.Votes;

                data.IsInEditMode      = false;
                data.EditVisible       = code.IsPrimaryVersion;
                data.BackToForkVisible = false;
                data.PrimaryGuid       = code.PrimaryGuid == null ? data.CodeGuid : code.PrimaryGuid;
                data.IsSaved           = true;
                if (data.PrimaryGuid != data.CodeGuid)
                {
                    data.LivesVersion = Model.IsLive(data.PrimaryGuid);
                }

                return(View(data));
            }

            data.IsLive       = false;
            data.IsInEditMode = false;

            if ((int)data.LanguageChoice != (int)LanguagesEnum.Unknown && (int)data.EditorChoice != (int)EditorsEnum.Unknown)
            {
                Model.SaveUserProfile(data.LanguageChoice, data.EditorChoice);
            }

            UserProfile profile = null;

            if ((int)data.LanguageChoice == (int)LanguagesEnum.Unknown || (int)data.EditorChoice == (int)EditorsEnum.Unknown)
            {
                profile = Model.GetUserProfile();
            }

            if ((int)data.LanguageChoice == (int)LanguagesEnum.Unknown)
            {
                data.LanguageChoice = profile.LanguageChoice;
            }

            if ((int)data.EditorChoice == (int)EditorsEnum.Unknown)
            {
                data.EditorChoice = profile.EditorChoice;
            }

            data.Program      = data.GetInitialCode(data.LanguageChoice, data.EditorChoice);
            data.CompilerArgs = data.GetInitialCompilerArgs(data.LanguageChoice);
            return(View(data));
        }