Exemplo n.º 1
0
        public Value GetValue(MdlFileContent file)
        {
            StringVal stringVal = new StringVal();

            stringVal.Value = file.Next();
            return(stringVal);
        }
Exemplo n.º 2
0
        public TypeElement GetTypeElement(MdlFileContent file)
        {
            Object obj = new Object();

            obj.Type = file.Next();
            IValueFactory valueFactory = new ValueFactory();

            if (file.Peek() != "\n")
            {
                obj.Name = file.Next();
                if (file.Peek() != "\n")
                {
                    obj.SecondName = file.Next();
                }
            }
            file.Next();
            while (file.Peek() != ")")
            {
                while (string.IsNullOrWhiteSpace(file.Peek()))
                {
                    file.Next();
                }
                Property property = new Property();
                property.Name  = file.Next();
                property.Value = valueFactory.GetValue(file);
                obj.Properties.Add(property);
            }
            return(obj);
        }
Exemplo n.º 3
0
        public Value GetValue(MdlFileContent file)
        {
            IntegerVal integerVal = new IntegerVal();

            integerVal.Value = int.Parse(file.Next());
            return(integerVal);
        }
Exemplo n.º 4
0
        public Value GetValue(MdlFileContent file)
        {
            DoubleVal doubleVal = new DoubleVal();

            doubleVal.Value = double.Parse(file.Next());
            return(doubleVal);
        }
Exemplo n.º 5
0
        public Value GetValue(MdlFileContent file)
        {
            BooleanVal booleanVal = new BooleanVal();

            booleanVal.Value = bool.Parse(file.Next());
            return(booleanVal);
        }
Exemplo n.º 6
0
        public Value GetValue(MdlFileContent file)
        {
            IdVal idVal = new IdVal();

            idVal.Value = int.Parse(file.Next().TrimStart('@'));
            return(idVal);
        }
Exemplo n.º 7
0
        public Value GetValue(MdlFileContent file)
        {
            IElementFactory elementFactory = new ElementFactory();
            ElementVal      elementVal     = new ElementVal();

            elementVal.Value = elementFactory.GetElement(file);
            return(elementVal);
        }
Exemplo n.º 8
0
        public TypeElement GetTypeElement(MdlFileContent file)
        {
            ValueFactory valueFactory = new ValueFactory();
            ValueElement valueElement = new ValueElement();

            valueElement.Value = valueFactory.GetValue(file);
            return(valueElement);
        }
Exemplo n.º 9
0
        public Value GetValue(MdlFileContent file)
        {
            file.Next();
            EnumVal enumVal = new EnumVal();

            enumVal.Name  = file.Next();
            enumVal.Value = int.Parse(file.Next());
            file.Next();
            return(enumVal);
        }
Exemplo n.º 10
0
        public Element GetElement(MdlFileContent file)
        {
            file.Next();
            string[] p        = file.Next().Split(',');
            Position position = new Position();

            position.X = long.Parse(p[0]);
            position.Y = long.Parse(p[1]);
            file.Next();
            return(position);
        }
Exemplo n.º 11
0
        public TypeElement GetTypeElement(MdlFileContent file)
        {
            IElementFactory elementFactory = new ElementFactory();

            StateMachine.MdlReader.List list = new List();
            list.Type = file.Next();
            while (file.Peek() != ")")
            {
                list.Elements.Add(elementFactory.GetElement(file));
            }
            return(list);
        }
Exemplo n.º 12
0
        public Value GetValue(MdlFileContent file)
        {
            int    intResult;
            double doubleResult;
            bool   boolResult;
            int    index = file.Index;

            IValueFactory valueFactory;

            if (file.Content[index] == "(" &&
                file.Content[index + 1].StartsWith("\"") &&
                int.TryParse(file.Content[index + 2], out intResult) &&
                file.Content[index + 3] == ")")
            {
                valueFactory = new EnumValFactory();
            }
            else if (file.Content[index] == "(" &&
                     file.Content[index + 1] == "value" &&
                     file.Content[index + 2] == "Text")
            {
                valueFactory = new TextValFactory();
            }
            else if (int.TryParse(file.Peek(), out intResult))
            {
                valueFactory = new IntegerValFactory();
            }
            else if (double.TryParse(file.Peek(), out doubleResult))
            {
                valueFactory = new DoubleValFactory();
            }
            else if (bool.TryParse(file.Peek(), out boolResult))
            {
                valueFactory = new BooleanValFactory();
            }
            else if (file.Peek().StartsWith("\"") || file.Peek().StartsWith("\n|"))
            {
                valueFactory = new StringValFactory();
            }
            else if (file.Peek().StartsWith("@"))
            {
                valueFactory = new IdValFactory();
            }
            else
            {
                valueFactory = new ElementValFacotory();
            }
            return(valueFactory.GetValue(file));
        }
Exemplo n.º 13
0
        public MDLFile Parse()
        {
            IElementFactory elementFactory = new ElementFactory();
            MdlFileContent  mdlFileContent = new MdlFileContent(path);
            MDLFile         file           = new MDLFile();

            while (!mdlFileContent.EndOfFile)
            {
                if (string.IsNullOrWhiteSpace(mdlFileContent.Peek()))
                {
                    mdlFileContent.Next(); continue;
                }
                file.Elements.Add(elementFactory.GetElement(mdlFileContent));
            }
            return(file);
        }
Exemplo n.º 14
0
        public Element GetElement(MdlFileContent file)
        {
            IElementFactory elementFactory;

            while (!file.EndOfFile && string.IsNullOrWhiteSpace(file.Peek()))
            {
                file.Next();
            }
            if (file.Content[file.Index] == "(" && regex.IsMatch(file.Content[file.Index + 1]))
            {
                elementFactory = new PositionFactory();
            }
            else
            {
                elementFactory = new TypeElementFactory();
            }
            return(elementFactory.GetElement(file));
        }
Exemplo n.º 15
0
        public Value GetValue(MdlFileContent file)
        {
            TextVal textVal      = new TextVal();
            int     bracketCount = 0;

            file.Next(); file.Next(); file.Next();
            while (bracketCount > 0 || file.Peek() != ")")
            {
                if (file.Peek() == "(")
                {
                    ++bracketCount;
                }
                else if (file.Peek() == ")")
                {
                    --bracketCount;
                }
                textVal.Value += file.Next();
            }
            file.Next();
            return(textVal);
        }
Exemplo n.º 16
0
        public TypeElement GetTypeElement(MdlFileContent file)
        {
            file.Next();
            string s = file.Next();
            ITypeElementFactory typeElementFactory;

            if (s.StartsWith("object"))
            {
                typeElementFactory = new ObjectFactory();
            }
            else if (s.StartsWith("list"))
            {
                typeElementFactory = new ListFactory();
            }
            else
            {
                typeElementFactory = new ValueElementFactory();
            }
            TypeElement typeElement = typeElementFactory.GetTypeElement(file);

            file.Next();
            return(typeElement);
        }
Exemplo n.º 17
0
 public Element GetElement(MdlFileContent file)
 {
     return(GetTypeElement(file));
 }