public static FieldContext BuildFieldContext(XElement declElement)
{
if (declElement == null)
{
throw new ArgumentNullException("declElement");
}
if (declElement.Name != SRC.Declaration)
{
throw new ArgumentException(string.Format("The passed XElement must represent a <decl> element. Received a <{0}> element.", declElement.Name.ToString()), "declElement");
}
FieldContext fc = new FieldContext();
//Type of the field
var typeElement = declElement.Element(SRC.Type);
if (typeElement != null)
{
bool isPrimitive;
fc.IdType = ConstructTypeName(typeElement, out isPrimitive);
fc.IdTypeIsPrimitive = isPrimitive;
}
//Determine declaring class
XElement classElement = FindEnclosingClassElement(declElement);
if (classElement != null && classElement.Element(SRC.Name) != null)
{
fc.DeclaringClass = GetNameFromNameElement(classElement.Element(SRC.Name));
}
return fc;
}