コード例 #1
0
        private string GetArgument(string opName, string friendlyInterpretation)
        {
            string value = "";

            if (friendlyInterpretation == null)
            {
                return(value);
            }

            Arguments argument;

            if (opName.Contains("FAST"))
            {
                argument = ArgumentsList.Where((Arguments x) => x.OpName.Contains("FAST") && x.Value.Equals(friendlyInterpretation)).LastOrDefault();
            }
            else
            {
                argument = ArgumentsList.Where((Arguments x) => x.OpName.Equals(opName) && x.Value.Equals(friendlyInterpretation)).LastOrDefault();
            }

            if (argument != null)
            {
                return(argument.Argument);
            }

            Arguments lastValue;

            if (opName.Contains("FAST"))
            {
                lastValue = ArgumentsList.Where(x => x.OpName.Contains("FAST")).LastOrDefault();
                value     = lastValue == null ? "0" : (int.Parse(lastValue.Argument) + 1).ToString();
            }
            else
            {
                if (opName.Contains("CONST"))
                {
                    lastValue = ArgumentsList.Where(x => x.OpName.Equals(opName)).LastOrDefault();
                    value     = lastValue == null ? "1" : (int.Parse(lastValue.Argument) + 1).ToString();
                }
                else if (opName.Contains("COMPARE"))
                {
                    lastValue = ArgumentsList.Where(x => x.OpName.Equals(opName)).LastOrDefault();
                    value     = lastValue == null ? "0" : (int.Parse(lastValue.Argument) + 1).ToString();
                }
            }

            argument = new Arguments
            {
                OpName   = opName,
                Value    = friendlyInterpretation,
                Argument = value
            };

            ArgumentsList.Add(argument);

            return(value);
        }