public string[] CreateXmlConfigurations(Assembly assembly)
{
object[] atts = assembly.GetCustomAttributes(true);
ArrayList namedQueries = new ArrayList();
ArrayList imports = new ArrayList();
ArrayList rawXml = new ArrayList();
foreach (object attribute in atts)
{
if (attribute is HqlNamedQueryAttribute)
{
namedQueries.Add(attribute);
}
else if (attribute is ImportAttribute)
{
imports.Add(attribute);
}
else if (attribute is RawXmlMappingAttribute)
{
string[] result = ((RawXmlMappingAttribute)attribute).GetMappings();
rawXml.AddRange(result);
}
}
xml.Append(Constants.XmlPI);
xml.AppendFormat(Constants.XmlHeader, "", "");
//note that there is a meaning to the order of import vs. named queries, imports must come first.
foreach (ImportAttribute attribute in imports)
{
AppendImport(attribute);
}
foreach (HqlNamedQueryAttribute attribute in namedQueries)
{
AppendNamedQuery(attribute, assembly);
}
xml.AppendLine(Constants.XmlFooter);
bool hasQueriesOrImportsToAdd = namedQueries.Count != 0 || imports.Count != 0;
if (hasQueriesOrImportsToAdd)
{
rawXml.Insert(0,xml.ToString());
}
Reset();
return (string[])rawXml.ToArray(typeof(string));
}