Пример #1
0
        private static bool TryParseProperty(Node node, Stack<string> nameStack, List<Mappable> mappables)
        {
            if (node.Children.Count == 0)
            {
                return false;
            }

            if (node.Words.Contains("("))
            {
                return false;
            }

            if (node.Children[0].Words.Count == 0 ||
                (node.Children[0].Words[0] != "get" && node.Children[0].Words[0] != "set"))
            {
                return false;
            }

            if (node.Words.Contains("private"))
            {
                return true;
            }

            var typeName = node.Words[node.Words.Count - 2];
            var propertyName = node.Words[node.Words.Count - 1];
            var mappable = new Mappable();
            mappables.Add(mappable);
            mappable.Name.AddRange(nameStack.Reverse());
            mappable.Name.Add(propertyName);
            mappable.TypeName = typeName;
            return true;
        }
Пример #2
0
        private static bool TryParseField(Node node, Stack<string> nameStack, List<Mappable> mappables)
        {
            if (node.Children.Count != 0)
            {
                return false;
            }

            if (node.Words.Contains("private"))
            {
                return true;
            }

            var lastWordIndex = node.Words.Count;
            var equalsIndex = node.Words.IndexOf("=");
            if (equalsIndex >= 0)
            {
                lastWordIndex = equalsIndex;
            }
            var typeName = node.Words[lastWordIndex - 2];
            var fieldName = node.Words[lastWordIndex - 1];

            var mappable = new Mappable();
            mappables.Add(mappable);
            mappable.Name.AddRange(nameStack.Reverse());
            mappable.Name.Add(fieldName);
            mappable.TypeName = typeName;
            return true;
        }