Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------------------------------------------

        private ParserResult <TTargetClass> CreateInstance(IReadOnlyList <string> mainArguments, string delimiter)
        {
            var arguments    = mainArguments.Select(x => x.Trim()).Select(x => x).ToList();
            var anticipating = 0; // 0 - init 1-cmd  2-regular without params 3-with params
            var nameProperty = string.Empty;

            for (int i = 0; i < arguments.Count;)
            {
                if (arguments[i].Equals(delimiter))
                {
                    i++;
                    anticipating = 1;
                    continue;
                }

                if (arguments[i][0].ToString() == delimiter)
                {
                    arguments[i] = arguments[i].Remove(0, 1).Trim();
                    anticipating = 1;
                    continue;
                }

                if (anticipating == 1)
                {
                    nameProperty = arguments[i];
                    anticipating = _tableContent[arguments[i++]].Parameters.Any() == false ? 2 : 3;
                    continue;
                }

                if (anticipating == 2)
                {
                    _tableContent.SetPropertyWithValue(nameProperty, arguments[i++]);
                    anticipating = 1;
                    continue;
                }

                if (anticipating == 3)
                {
                    //TODO
                    throw new NotImplementedException();
                }
            }



            return(new ParserResult <TTargetClass>(isSucceeded: true, exceptions: null, targetClass: _tableContent.RetreiveInstance()));
        }