예제 #1
0
 public static TableOfRecords GlobalRecords()
 {
     if (instance == null)
     {
         instance = new TableOfRecords("global_records", 10);
     }
     return(instance);
 }
예제 #2
0
 public static TableOfRecords OwnRecords()
 {
     if (instance == null)
     {
         instance = new TableOfRecords("own_records", 5);
     }
     return(instance);
 }
예제 #3
0
    public void OnPlayerDead()
    {
        showDeathUI();
        TableOfRecords.OwnRecords().AddRecord(new GameRecord("Лудший чувак", scores));
        string result = "";

        foreach (var i in TableOfRecords.OwnRecords().Records)
        {
            result += i.PlayerName + ": " + i.Score + "\n";
        }
        recordsText.text = result;
    }
        /// <summary>
        /// Command handler.
        /// </summary>
        /// <param name="appCommandRequest">Request.</param>
        public override void Handle(AppCommandRequest appCommandRequest)
        {
            if (appCommandRequest is null)
            {
                throw new ArgumentNullException($"{nameof(appCommandRequest)} is null");
            }

            if (this.GoToNextCommand(appCommandRequest))
            {
                return;
            }

            string[] printFieldsNames;
            List <List <(string, string)> > logicalСonditionsList;
            bool result;
            var  propertiesFileCabinetRecord = typeof(FileCabinetRecord).GetProperties();

            (printFieldsNames, logicalСonditionsList, result) = SelectParcer(appCommandRequest.Parameters);

            if (!result)
            {
                Console.WriteLine("Invalid parameters");
                return;
            }

            var printProperties = GetProperties(propertiesFileCabinetRecord, printFieldsNames);

            if (printProperties is null)
            {
                Console.WriteLine("No such properties found");
                return;
            }

            var records          = new FileCabinetRecord[logicalСonditionsList.Count];
            var searchProperties = new List <PropertyInfo[]>();

            for (int i = 0; i < logicalСonditionsList.Count; i++)
            {
                var fieldsNames  = new string[logicalСonditionsList[i].Count];
                var fieldsValues = new string[logicalСonditionsList[i].Count];
                for (int j = 0; j < logicalСonditionsList[i].Count; j++)
                {
                    fieldsNames[j]  = logicalСonditionsList[i][j].Item1;
                    fieldsValues[j] = logicalСonditionsList[i][j].Item2;
                }

                var searchProperty = GetProperties(propertiesFileCabinetRecord, fieldsNames);
                if (searchProperty is null)
                {
                    Console.WriteLine("No such properties found");
                    return;
                }

                searchProperties.Add(searchProperty);
                var tempRecord = GetRecord(searchProperties[i], fieldsNames, fieldsValues);
                if (tempRecord is null)
                {
                    Console.WriteLine("Сould not match values to properties");
                    return;
                }

                records[i] = tempRecord;
            }

            var tableOfRecords = new TableOfRecords <FileCabinetRecord>(this.service.SelectRecords(searchProperties.ToArray(), records), printProperties);

            tableOfRecords.PrintTable(this.recordPrinter);
        }