Beispiel #1
0
 public BerryContext() {
     if (VM_Berry == null) {
         VM_Berry = new BerryViewModel();
     }
     if (VM_Item == null) {
         VM_Item = new ItemViewModel();
     }
     if (VM_Type == null) {
         VM_Type = new TypeViewModel();
     }
     if (VM_Category == null) {
         VM_Category = new CategoryViewModel();
     }
     if (VM_Pocket == null) {
         VM_Pocket = new PocketViewModel();
     }
     if (VM_Generation == null) {
         VM_Generation = new GenerationViewModel();
     }
     if (VM_Region == null) {
         VM_Region = new RegionViewModel();
     }
     if (VM_DamageClass == null) {
         VM_DamageClass = new DamageClassViewModel();
     }
     if (VM_Language == null) {
         VM_Language = new LanguageViewModel();
     }
     if (VM_ContestType == null) {
         VM_ContestType = new ContestTypeViewModel();
     }
 }
Beispiel #2
0
        public IActionResult Generation(GenerationViewModel model)
        {
            var context = HttpContext;

            if (ModelState.IsValid)
            {
                string shortUrl = GetRandomUrl();
                while (_db.UrlTable.Any(ur => ur.ShortUrl == shortUrl))
                {
                    shortUrl = GetRandomUrl();
                }
                var url = new Urls();
                url.Url        = model.Url;
                url.NumOfClick = 0;
                url.ShortUrl   = shortUrl;
                if (User.Identity.IsAuthenticated)
                {
                    url.Username = User.Identity.Name;
                    _db.UrlTable.Add(url);
                    _db.SaveChanges();
                }
                else
                {
                    url.Username = null;
                    _urlService.AddUrl(url, context);
                }
                return(View("UrlReturn", "https://" + HttpContext.Request.Host + "/" + shortUrl));
            }

            return(View());
        }
        public void Setup()
        {
            _spyWriter = new Mock <IWriter>();
            _presenter = new CommandLinePresenter(_spyWriter.Object);

            _testGenerationViewModel = new GenerationViewModel(GridCreator.GetOnlyAliveCenterGrid(), 0);
        }
Beispiel #4
0
        public IActionResult Generations()
        {
            GenerationViewModel model = new GenerationViewModel()
            {
                AllGenerations = this.dataService.GetObjects <Generation>(),
                AllGames       = this.dataService.GetObjects <Game>("ReleaseDate, Id"),
            };

            return(this.View(model));
        }
        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            ViewModel = e.NewValue as GenerationViewModel;

            if (ViewModel is null)
            {
                return;
            }

            ViewModel.Generate
            .IsExecuting
            .ObserveOnDispatcher()
            .Subscribe(executing => Cursor = executing ? Cursors.Wait : Cursors.Arrow);

            switch (ViewModel.Preferences.FogMethod)
            {
            case FogGenerationMethod.ChangeEveryNthBar:
                fogNthBarRB.IsChecked = true;
                break;

            case FogGenerationMethod.MinTimeBetweenChanges:
                fogMinTimeRB.IsChecked = true;
                break;

            case FogGenerationMethod.FromSectionNames:
                fogPerSectionRB.IsChecked = true;
                break;

            case FogGenerationMethod.FromChords:
                fogChordsRB.IsChecked = true;
                break;

            case FogGenerationMethod.FromLowestOctaveNotes:
                fogLowOctaveRB.IsChecked = true;
                break;
            }

            switch (ViewModel.Preferences.BeamMethod)
            {
            case BeamGenerationMethod.FollowFogNotes:
                beamFollowFogRB.IsChecked = true;
                break;

            case BeamGenerationMethod.MinTimeBetweenChanges:
                beamMinTimeRB.IsChecked = true;
                break;
            }
        }
Beispiel #6
0
 public AbilityContext() {
     if (VM_Ability == null) {
         VM_Ability = new AbilityViewModel();
     }
     if (VM_Generation == null) {
         VM_Generation = new GenerationViewModel();
     }
     if (VM_Region == null) {
         VM_Region = new RegionViewModel();
     }
     if (VM_VersionGroups == null) {
         VM_VersionGroups = new VersionGroupsViewModel();
     }
     if (VM_Language == null) {
         VM_Language = new LanguageViewModel();
     }
 }
        public OperationResult CodeGeneration(GenerationViewModel gen)
        {
            var projectDirectory = GetSolutionDir();//ConfigurationManager.AppSettings["ProjectDirectory"];
            var hash             = new Dictionary <string, object>();
            var properties       = Type.GetType("App.Core.Domain." + gen.model.ModelName + ",App.Core").GetProperties();

            hash.Add("dtoFields", properties);
            hash.Add("properties", properties);
            hash.Add("model", gen.model);

            var nvelocity = NVelocityHelper.GetInstance().GetTemplate(gen.option, "/admin/GenerationTemplates/", hash);

            var outputPath = string.Format(projectDirectory + gen.outputPath, gen.model.ModelGroup, gen.model.ModelName);

            FileOperate.WriteFile(outputPath, nvelocity.ToString());

            return(new OperationResult {
                success = true, message = "位置:" + outputPath
            });
        }
        public void WriteLine_Should_Get_Called_With_Correct_Output(GenerationViewModel generation, string expected)
        {
            _presenter.Display(generation);

            _spyWriter.Verify(w => w.WriteLine(expected), Times.Once);
        }