Ejemplo n.º 1
0
 void fixWidgetProperties(WrapperResult result)
 {
     foreach (var element in result.Element)
     {
         fixWidgetProperties(element);
     }
 }
Ejemplo n.º 2
0
 void calculateElementRecursion(WrapperResult result)
 {
     foreach (var element in result.Element)
     {
         calculateElementRecursion(element);
     }
 }
Ejemplo n.º 3
0
        public WrapperResult parse()
        {
            if (_scriptText == null)
            {
                return(null);
            }
#if DEBUG
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Raw:>\n{0}", _scriptText);
            Console.ResetColor();
#endif
            _scriptText = deleteCommentText();

            //fix special char
            _scriptText = _scriptText.Replace("\r\n", "\n").Replace("\t", string.Empty).Replace("\n\n", "\n");

            int  position = -1;
            char ch       = (char)0;

            WrapperResult elementResult = new WrapperResult();

            ElementBase currentElement = null, element;

#if DEBUG
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DeleteComments:>\n{0}", _scriptText);
            Console.ResetColor();
            string AccessedString = "";
#endif

            while (true)
            {
                position++;
                if (position >= _scriptText.Length)
                {
                    break;
                }

                ch = _scriptText[position];

#if DEBUG
                AccessedString += ch;
#endif

                if (ch == '[')
                {
                    Stack <int> balanceBracket = new Stack <int>();
                    balanceBracket.Push(position);
                    string buffer = selectElement(ref position);
                    element = parseSelectElementText(ref buffer);

                    //set parantElement up
                    element.ParentElement = getCurrentParantElement();
                    if (getCurrentParantElement() != null)
                    {
                        element.ParentElement.ChildrenElement.Add(element);
                    }

                    currentElement = element;

                    if (element.ParentElement == null)
                    {
                        elementResult.Element.Add(element);
                    }
                }

                if (ch == '{')
                {
                    elementParentStack.Push(currentElement);
                }

                if (ch == '}')
                {
                    elementParentStack.Pop();
                }
            }

            calculateElementRecursion(elementResult);

            fixWidgetProperties(elementResult);

            return(elementResult);
        }