public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Solution,Problem,ProjectEulerLink")] CodeSolution codeSolution)
        {
            if (id != codeSolution.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(codeSolution);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CodeSolutionExists(codeSolution.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(codeSolution));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Solution,Problem,ProjectEulerLink")] CodeSolution codeSolution)
        {
            if (ModelState.IsValid)
            {
                _context.Add(codeSolution);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(codeSolution));
        }
Beispiel #3
0
        /// <summary>
        /// Invoked from unmanaged code to initialize CryBrary subsystems.
        /// </summary>
        /// <param name="configurationPath">
        /// Path to configuration files and utilities.
        /// </param>
        internal MonoInterface(string configurationPath)
        {
            ProjectSettings.ConfigFolder = configurationPath;
            // Load and build the solution.
            CodeSolution.Load(Path.Combine(CryPak.CodeFolder, "Solutions", "CryMonoCode.sln"));
            this.CompiledAssemblies = CodeSolution.Build();
            // Find types that require registration for interoperability with CryEngine.
            this.RegisterCryEngineTypes();
#if DEBUG
            // Check the types that are used in marshaling for blittability.
            AppDomain.CurrentDomain.GetAssemblies()
            .SelectMany
            (
                assembly =>
                assembly.GetTypes()
                .Where(x => x.ContainsAttribute <BlittableAttribute>())
            )
            .ForEach(BlitChecker.Check);
#endif
        }
Beispiel #4
0
        /// <summary>
        /// Called from C++ code to initialize CryCIL on C# side.
        /// </summary>
        private MonoInterface()
        {
            Application.EnableVisualStyles();
            // Register default handling of exceptions.
            AppDomain.CurrentDomain.UnhandledException +=
                (sender, args) => MonoInterface.DisplayException(args.ExceptionObject);
            // Redirect Console output.
            Console.SetOut(new ConsoleLogWriter());
            // Load all extra modules.
            string gameModulesFolder = Path.Combine
                                           (DirectoryStructure.ContentFolder, "Modules", "CryCIL");
            string cryEngineModulesFolder = Path.Combine
                                                (DirectoryStructure.CryEngineFolder, "Modules", "CryCIL");
            List <string> gameModules      = new List <string>();
            List <string> cryEngineModules = new List <string>();

            if (Directory.Exists(gameModulesFolder))
            {
                gameModules.AddRange(Directory.GetFiles(gameModulesFolder, "*.dll"));
            }
            if (Directory.Exists(cryEngineModulesFolder))
            {
                cryEngineModules.AddRange(Directory.GetFiles(cryEngineModulesFolder, "*.dll"));
            }

            this.CryCilAssemblies = new List <Assembly>
                                    (
                from file in gameModules.Concat(cryEngineModules)
                where AssemblyExtras.IsAssembly(file)
                select Assembly.Load(AssemblyName.GetAssemblyName(file))
                                    );
            // Load and compile the solution.
            this.OnCompilationStarted();
            try
            {
                bool loadingSuccessful =
                    CodeSolution.Load
                    (
                        Path.Combine
                        (
                            DirectoryStructure.ContentFolder,
                            "Code", "Solutions", "CryCilCode.sln"
                        )
                    );
                if (!loadingSuccessful)
                {
                    throw new Exception("Unable to load the solution.");
                }
                this.CryCilAssemblies.AddRange(CodeSolution.Build());
                this.OnCompilationComplete(true);
            }
            catch (Exception)
            {
                this.OnCompilationComplete(false);
            }
            // Add Cryambly to the list.
            this.CryCilAssemblies.Add(Assembly.GetAssembly(typeof(MonoInterface)));
            // A simple test for redirected console output.
            Console.Write(this.CryCilAssemblies.Count);
            Console.WriteLine(" CryCIL-specific assemblies are loaded.");
            Console.WriteLine("Proceeding to stage-based initialization.");
            this.ProceedWithInitializationStages();
        }