Ejemplo n.º 1
0
    private IDataGetter CombineDataFromStorages(IDataGetter currentData, IDataGetter receivedData)
    {
        // currentData по определению не может быть null
        if (currentData == null)
        {
            throw new ArgumentNullException(nameof(currentData));
        }
        // receivedData может быть null
        if (receivedData == null)
        {
            return(currentData);
        }

        if (currentData.Equals(receivedData))
        {
            return(currentData);
        }
        else
        {
            IDataGetter returnedDataGetter;

            if (currentData.Id != receivedData.Id)
            {
                // TODO: Вывод диалогового окна
                throw new NotImplementedException();
            }
            else
            {
                // TODO: скомбинировать значения полей по правилам.
                returnedDataGetter = new LastSessionsDataGetter(currentData, receivedData);
            }

            readerWriter.WriteAllData(new PlayerGameData(returnedDataGetter));
            return(returnedDataGetter);
        }
    }