Beispiel #1
0
        private StructureProperty ParseProperty(string line, int lineNumber)
        {
            StructureProperty result = new StructureProperty();
            string[] tokens = line.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            string name = tokens[0].Trim();
            if (name.EndsWith("?"))
            {
                result.IsNullable = true;
                name = name.Substring(0, name.Length - 1);

            }
            else if (name.EndsWith("+"))
            {
                result.IsPrimaryKey = true;
                name = name.Substring(0, name.Length - 1);

            }
            else if (name.EndsWith("*"))
            {
                result.IsPrimaryKey = true;
                result.IsIdentity = true;
                name = name.Substring(0, name.Length - 1);
            }
            result.Name = name;
            if (tokens.Length == 1)
            {
                result.ReferenceName = result.Name;
            }
            else
            {
                string referenceName = tokens[1].Trim();
                if (string.IsNullOrEmpty(referenceName))
                {
                    result.ReferenceName = string.Empty;
                }
                else
                {
                    if (referenceName.StartsWith("$"))
                    {
                        result.ReferenceName = referenceName.Substring(1);
                    }
                    else
                    {
                        result.ReferenceName = referenceName;
                        result.IsTyped = true;
                        string typeName = this.PopParenthesis(ref referenceName);
                        result.DataTypeStr = typeName;
                        result.DataType = this.CalculateDataType(typeName, lineNumber);
                        referenceName = referenceName.Trim();
                        result.DataTypeLength = 0;
                        result.DataTypeDecimals = 0;
                        if (!string.IsNullOrEmpty(referenceName))
                        {
                            string[] lengths = referenceName.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                            result.DataTypeLength = Convert.ToInt32(lengths[0].Trim());
                            if (lengths.Length > 1)
                            {
                                result.DataTypeDecimals = Convert.ToInt32(lengths[1].Trim());
                            }
                        }
                    }
                }
            }
            return result;
        }
Beispiel #2
0
        private StructureProperty ParseProperty(string line, int lineNumber)
        {
            StructureProperty result = new StructureProperty();

            string[] tokens = line.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            string   name   = tokens[0].Trim();

            if (name.EndsWith("?"))
            {
                result.IsNullable = true;
                name = name.Substring(0, name.Length - 1);
            }
            else if (name.EndsWith("+"))
            {
                result.IsPrimaryKey = true;
                name = name.Substring(0, name.Length - 1);
            }
            else if (name.EndsWith("*"))
            {
                result.IsPrimaryKey = true;
                result.IsIdentity   = true;
                name = name.Substring(0, name.Length - 1);
            }
            result.Name = name;
            if (tokens.Length == 1)
            {
                result.ReferenceName = result.Name;
            }
            else
            {
                string referenceName = tokens[1].Trim();
                if (string.IsNullOrEmpty(referenceName))
                {
                    result.ReferenceName = string.Empty;
                }
                else
                {
                    if (referenceName.StartsWith("$"))
                    {
                        result.ReferenceName = referenceName.Substring(1);
                    }
                    else
                    {
                        result.ReferenceName = referenceName;
                        result.IsTyped       = true;
                        string typeName = this.PopParenthesis(ref referenceName);
                        result.DataTypeStr      = typeName;
                        result.DataType         = this.CalculateDataType(typeName, lineNumber);
                        referenceName           = referenceName.Trim();
                        result.DataTypeLength   = 0;
                        result.DataTypeDecimals = 0;
                        if (!string.IsNullOrEmpty(referenceName))
                        {
                            string[] lengths = referenceName.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                            result.DataTypeLength = Convert.ToInt32(lengths[0].Trim());
                            if (lengths.Length > 1)
                            {
                                result.DataTypeDecimals = Convert.ToInt32(lengths[1].Trim());
                            }
                        }
                    }
                }
            }
            return(result);
        }