Beispiel #1
0
        public async void SaveAsync <T>(T a) where T : class
        {
            if (typeof(T) == typeof(Models.Backlog))
            {
                Backlog.Add(a as Models.Backlog);
                await SaveChangesAsync();
            }
            else if (typeof(T) == typeof(Models.Project))
            {
                Project.Add(a as Models.Project);
                await SaveChangesAsync();
            }
            else if (typeof(T) == typeof(Models.Sprint))
            {
                Sprint.Add(a as Models.Sprint);
                await SaveChangesAsync();
            }

            else if (typeof(T) == typeof(Models.Step))
            {
                Step.Add(a as Models.Step);
                await SaveChangesAsync();
            }
            else if (typeof(T) == typeof(Models.Task))
            {
                Task.Add(a as Models.Task);
                await SaveChangesAsync();
            }
            else if (typeof(T) == typeof(Models.User))
            {
                User.Add(a as Models.User);
                await SaveChangesAsync();
            }
        }
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (Tbstock.FontFamily.ToString() == Tbuser.FontFamily.ToString() &&
                Tbstock.FontSize == Tbuser.FontSize &&
                Tbstock.FontStyle == Tbuser.FontStyle &&
                Tbstock.FontWeight == Tbuser.FontWeight &&
                _r == Convert.ToInt32(TextBoxR.Text) &&
                _g == Convert.ToInt32(TextBoxG.Text) &&
                _b == Convert.ToInt32(TextBoxB.Text))
            {
                MessageBox.Show("Вы угадали все параметры! Ваш результат: " + _newcount + " шагов");
                Sc.Add(_score); Step.Add(_newcount);
                using (var sw = File.AppendText(_file))
                    sw.WriteLine("- Попытка проверить все параметры: удачно");
                using (var sw = File.AppendText(_filesteps))
                    sw.WriteLine("{0} ", Sc.Last());
                using (var sw = File.AppendText(_filescore))
                    sw.WriteLine("{0} ", Step.Last());

                var dlg = new Score();
                dlg.ShowDialog();

                Close();
            }
            else
            {
                MessageBox.Show("Параметры не совпали! Попробуйте на следующем шаге!");
                //score--;
                Label7.Content = _score.ToString() + " очков";
                using (var sw = File.AppendText(_file))
                    sw.WriteLine("- Попытка проверить все параметры: тщетно. Очки -1");
            }
            Button2.IsEnabled = false;
        }
        private void button8_Click(object sender, RoutedEventArgs e)
        {
            Sc.Add(_score); Step.Add(_newcount);
            using (var sw = File.AppendText(_file))
                sw.WriteLine("- Игрок сдался!");
            using (var sw = File.AppendText(_filesteps))
                sw.WriteLine("{0}", Sc.Last());
            using (var sw = File.AppendText(_filescore))
                sw.WriteLine("{0}", Step.Last());
            var dlg = new Score();

            dlg.ShowDialog();

            Close();
        }
Beispiel #4
0
 // ----------------------------------------------------------------------------------------
 /// <!-- Append -->
 /// <summary>
 ///      Appends the steps of a new Result on to the ResultStep list
 /// </summary>
 /// <param name="result"></param>
 /// <returns></returns>
 public Result Append(Result result)
 {
     if (result.Count > 0)
     {
         if (Last.TestResult != ResultStatus.Untested)
         {
             Step.Add(result[0]);
         }
         else
         {
             And(result, 0);
         }
         for (int i = 1; i < result.Count; ++i)
         {
             Step.Add(result[i]);
         }
     }
     return(this);
 }
Beispiel #5
0
        public static void LoadFromYaml(this CompositionExecutor executor, FileInfo file)
        {
            if (executor is null)
            {
                throw new ArgumentNullException(nameof(executor));
            }
            if (file is null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            var    serializer = new Deserializer();
            string yaml       = File.ReadAllText(file.FullName);
            var    config     = serializer.Deserialize <YamlConfig>(yaml);

            foreach ((string name, CompositionConfig compositionCfg) in config.Compositions)
            {
                if (compositionCfg.Steps is null)
                {
                    continue;
                }

                var composition = new Composition(name, compositionCfg.Description);

                foreach ((string stepName, StepConfig stepCfg) in compositionCfg.Steps)
                {
                    if (!config.Composers.TryGetValue(stepCfg.Composer, out string composerTypeName))
                    {
                        throw new InvalidOperationException($"Cannot find composer named '{stepCfg.Composer}.");
                    }
                    Type composerType = Type.GetType(composerTypeName);
                    var  step         = new Step(stepName, composerType);
                    foreach (var(key, value) in stepCfg.Properties)
                    {
                        step.Add(key.Pascalize(), value);
                    }
                    composition.Add(step);
                }

                executor.Add(composition);
            }
        }
Beispiel #6
0
 private Result Append(object lhs, string operation, object rhs, ResultStatus status, string name, string method, Result inner)
 {
     Step.Add(new ResultStep(lhs, operation, rhs, status, name, method, inner)); return(this);
 }