예제 #1
0
        private static SavePair ShiftBy(int length, SavePair savePair)
        {
            var separatorIndex = savePair.Value.IndexOf('.');

            var integer = int.Parse
                              (separatorIndex == -1
                    ? savePair.Value
                    : savePair.Value.Substring(0, separatorIndex));

            integer = integer + length;

            if (integer < 0)
            {
                integer = 0;
            }

            var postfix = string.Empty;

            if (separatorIndex == -1)
            {
                return(new SavePair(savePair.Key, $"{integer}{postfix}"));
            }

            postfix = savePair.Value.Substring
                          (separatorIndex + 1,
                          savePair.Value.Length - separatorIndex - 1);

            postfix = $".{postfix}";

            return(new SavePair(savePair.Key, $"{integer}{postfix}"));
        }
예제 #2
0
        private static IReadOnlyCollection <SavePair> ReplacePairValue
            (IEnumerable <SavePair> savePairs, string key, string newValue)
        {
            var newSavePairs = savePairs.ToArray();

            var sizePairIndex = newSavePairs
                                .Select((p, i) => new { p.Key, Index = i })
                                .Single(r => r.Key == key)
                                .Index;

            newSavePairs[sizePairIndex] = new SavePair(key, newValue);

            return(newSavePairs);
        }
예제 #3
0
        private SavePair ShiftEverything(SavePair savePair)
        {
            // ReSharper disable SimplifyLinqExpression
            if (savePair.Key.EndsWith(".x") &&
                !m_ExcludedPairKeys.Any(k => $"{k}.x" == savePair.Key))
            {
                return(ShiftBy(-18, savePair));
            }

            if (savePair.Key.EndsWith(".y") &&
                !m_ExcludedPairKeys.Any(k => $"{k}.y" == savePair.Key))
            {
                return(ShiftBy(-25, savePair));
            }
            // ReSharper restore SimplifyLinqExpression

            return(savePair);
        }