コード例 #1
0
        static EntityTemplate parseTemplateDeclaration(DBJobData jobdata, string line)
        {
            EntityTemplate template = new EntityTemplate();

            template.fileLine = jobdata.line;
            template.filepath = jobdata.path;
            string name        = "NoNameEntity";
            string IDandParent = "";
            bool   hasName     = false;

            if (line.Contains('"'))
            {
                int count      = 0;
                int indx_start = 0;
                int indx_end   = 0;

                for (int i = 0; i < line.Length; i++)
                {
                    if (line[i] == '"')
                    {
                        count++;
                        if (count == 1)
                        {
                            indx_start = i;
                        }

                        if (count == 2)
                        {
                            indx_end = i;
                        }
                    }
                }
                if (count == 2)
                {
                    name    = line.Remove(indx_end, line.Length - indx_end);
                    name    = name.Remove(0, indx_start + 1);
                    hasName = true;
                }
                if (count == 1 || count > 2)
                {
                    jobdata.error = "Syntax error, check quotes in entity declaration";
                }
            }
            if (hasName)
            {
                IDandParent = line.Replace("\"" + name + "\"", string.Empty);
            }
            else
            {
                IDandParent = line;
            }

            template.Name = name;
            string[] split = IDandParent.Split(' ');

            bool foundID       = false;
            bool foundParentID = false;

            for (int i = 0; i < split.Length; i++)
            {
                if (split[i].Length == 0)
                {
                    continue;
                }
                else
                {
                    if (!foundID)
                    {
                        foundID             = true;
                        template.databaseID = split[i];
                    }
                    else
                    if (!foundParentID)
                    {
                        foundParentID     = true;
                        template.parentID = split[i];
                    }
                    else
                    {
                        jobdata.error = "Syntax error, too much members on entity declaration!";
                    }
                }
            }

            return(template);
        }
コード例 #2
0
        static Dictionary <string, string> parseComponent(DBJobData jobdata, string line, EntityTemplate template)
        {
            string component = "";

            if (line.Contains('[') && line.Contains(']'))
            {
                int    start = line.IndexOf('[');
                int    end   = line.IndexOf(']');
                char[] name  = new char[end - start - 1];

                int count = 0;
                for (int i = start + 1; i < end; i++)
                {
                    name[count] = line[i];
                    count++;
                }
                component = new string(name);
            }
            else
            {
                jobdata.error = "Syntax error, check brackets in component declaration declaration";
            }
            //if (!componentExists(component))
            //{
            //    jobdata.warnings.Add("Component [" + component + "] not found in system, make sure you spelled it right.");
            //}

            if (template.components.ContainsKey(component))
            {
                jobdata.error = "Duplicate component found, this is not allowed.";
            }
            else
            {
                template.components.Add(component, new Dictionary <string, string>());
                return(template.components[component]);
            }

            return(null);
        }