public static object Process <TModel>(TModel instance, MemberInfo m) { var aquire = ModelCompiler <TModel> .Compile(m); return(aquire(instance)); }
private async void compile_Click(object sender, EventArgs e) { Stopwatch trackCompileTime = new Stopwatch(); trackCompileTime.Start(); output.Text = ""; outputQueue.Clear(); compileProgress.Value = 0; foreach (Control control in CONTROLS_TO_DISABLE_WHEN_COMPILING) { control.Enabled = false; } Compiler.UseWaitCursor = true; ModelCompiler.PreScheduleTasks(); Func <AssemblerData> assemble; if (compilerTypeSelect.Text == "Avatar") { var assembler = new CharacterAssembler(); var userAvatar = UserAvatar.FromUsername(currentUser.Username); assemble = new Func <AssemblerData>(() => assembler.Assemble(userAvatar)); } else { var assembler = new CatalogItemAssembler(); assemble = new Func <AssemblerData>(() => assembler.Assemble(currentAssetId)); } Task <AssemblerData> buildModel = Task.Run(assemble); while (!buildModel.IsCompleted) { await UpdateCompilerState(); } if (buildModel.IsFaulted) { LogException(buildModel, "assemble"); } else { AssemblerData data = buildModel.Result; Task <string> compileModel = ModelCompiler.Compile(selectedGame, data); while (!compileModel.IsCompleted) { await UpdateCompilerState(); } if (compileModel.IsFaulted) { LogException(compileModel, "compile"); } else { PrintHeader("FINISHED MODEL!"); trackCompileTime.Stop(); Print("Assembled in {0} seconds.", trackCompileTime.Elapsed.TotalSeconds); await UpdateCompilerState(); compileModel.Wait(); latestCompiledModel = compileModel.Result; latestCompiledOnGame = selectedGame; } } foreach (Control control in CONTROLS_TO_DISABLE_WHEN_COMPILING) { control.Enabled = true; } if (trackCompileTime.IsRunning) { trackCompileTime.Stop(); } Compiler.UseWaitCursor = false; progressQueue.Clear(); }
public static object Process <TModel>(TModel instance, MemberInfo m) { return(ModelCompiler <TModel> .Compile(m)(instance)); }