protected async override Task OnInitializedAsync() { Config = new Models.OptimizerConfiguration { StartDate = DateTime.Now.AddDays(-1), EndDate = DateTime.Now, Fitness = new Models.FitnessConfiguration(), Genes = new Models.GeneConfiguration[] { new Models.GeneConfiguration() } }; //todo: allow upload of fitness //FitnessTypeNameOptions = Jtc.Optimization.Objects.FitnessTypeNameOptions.Options; assembly.GetTypes().Where(w => w.GetInterfaces().Contains(typeof(IFitness))).Select(s => s.FullName).OrderBy(o => o); using (dynamic context = new EvalContext(JSRuntime)) { (context as EvalContext).Expression = () => context.MainInterop.fetchConfig(); var json = await(context as EvalContext).InvokeAsync <string>(); if (!string.IsNullOrEmpty(json)) { Config = JsonSerializer.Deserialize <Models.OptimizerConfiguration>(json, _options); } } ToggleFitness(); using (dynamic context = new EvalContext(JSRuntime)) { (context as EvalContext).Expression = () => context.jQuery("body").css("overflow-y", "scroll"); } await base.OnInitializedAsync(); }
private void StoreConfig(Models.OptimizerConfiguration value) { var settings = new EvalContextSettings(); settings.SerializableTypes.Add(typeof(Models.OptimizerConfiguration)); using (dynamic context = new EvalContext(JSRuntime, settings)) { var serialized = JsonSerializer.ToJsonString(value); (context as EvalContext).Expression = () => context.ClientStorage.storeConfig(serialized); } BlazorClientState.NotifyStateHasChanged(typeof(SidebarBase)); }