Ejemplo n.º 1
0
        public override string Serialize()
        {
            var sb = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings()
            {
                OmitXmlDeclaration = true
            };

            using (XmlWriter w = XmlWriter.Create(sb, settings))
            {
                w.WriteStartElement(GetType().Name);
                base.Serialize(w);
                w.WriteAttributeString("name", Name);
                w.WriteAttributeString("databasename", databaseName.ToString());
                w.WriteAttributeString("installationcode", installationCode.ToString());
                w.WriteAttributeString("relateddbobject", relatedDBObject);
                w.WriteAttributeString("datasourcename", datasourceName);
                w.WriteAttributeString("dynamicuiname", dynamicUIName);
                w.WriteAttributeString("tablename", tableName);
                w.WriteAttributeString("dbobjecttype", DBObjectType.ToString());

                foreach (QChangeRequest cr in Children)
                {
                    w.WriteRaw(cr.Serialize());
                }

                w.WriteEndElement();
                w.Flush();
            }
            return(sb.ToString());
        }
        public static string AddSchema(string text, DBObjectType objectType, string schema, string name)
        {
            text = text.Trim();

            string operationPrefix = $"CREATE {objectType.ToString()}";

            if (text.StartsWith(operationPrefix, StringComparison.InvariantCultureIgnoreCase))
            {
                if (text.StartsWith($"{operationPrefix} {schema}.{name}", StringComparison.InvariantCultureIgnoreCase))
                {
                    // add brackets.
                    text = Regex.Replace(text, $"{operationPrefix} {schema}.{name}", $"{operationPrefix} [{schema}].[{name}]", RegexOptions.IgnoreCase);
                }
                else if (text.StartsWith($"{operationPrefix} {name}", StringComparison.InvariantCultureIgnoreCase))
                {
                    // add schema and brackets.
                    text = Regex.Replace(text, $"{operationPrefix} {name}", $"{operationPrefix} [{schema}].[{name}]", RegexOptions.IgnoreCase);
                }
                else if (text.StartsWith($"{operationPrefix} [{name}]", StringComparison.InvariantCultureIgnoreCase))
                {
                    // add schema.
                    text = Regex.Replace(text, $"{operationPrefix} \\[{name}\\]", $"{operationPrefix} [{schema}].[{name}]", RegexOptions.IgnoreCase);
                }
                else if (text.StartsWith($"{operationPrefix} [{schema}].[{name}]", StringComparison.InvariantCultureIgnoreCase))
                {
                    // add schema.
                    text = Regex.Replace(text, $"{operationPrefix} \\[{schema}\\].\\[{name}\\]", $"{operationPrefix} [{schema}].[{name}]", RegexOptions.IgnoreCase);
                }
            }

            return(text);
        }