private MetadataCompoundAttribute addUsageFromMetadataCompoundAttributeToMetadataCompoundAttribute(MetadataCompoundAttribute parent, MetadataCompoundAttribute compoundAttribute, XmlSchemaElement element)
{
if (parent.MetadataNestedAttributeUsages.Where(p => p.Label == element.Name).Count() <= 0)
{
//get max
int max = Int32.MaxValue;
if (element.MaxOccurs < Int32.MaxValue)
{
max = Convert.ToInt32(element.MaxOccurs);
}
MetadataNestedAttributeUsage usage = new MetadataNestedAttributeUsage()
{
Label = element.Name,
Description = GetDescription(element.Annotation),
MinCardinality = Convert.ToInt32(element.MinOccurs),
MaxCardinality = max,
Master = parent,
Member = compoundAttribute,
};
#region choice
//if element is a choise
XmlDocument extra = new XmlDocument();
//check if element is a choice
if (XmlSchemaUtility.IsChoiceType(element))
{
extra = XmlDatasetHelper.AddReferenceToXml(new XmlDocument(), "choice", "true", "elementType",@"extra/type");
}
if (extra.DocumentElement != null) usage.Extra = extra;
#endregion
parent.MetadataNestedAttributeUsages.Add(usage);
}
return parent;
}