public static void GetMethodAttributes(List<MethodInfo> methodInfos, out List<object> methodAttributes, out List<List<object>> argumentAttributes)
{
methodAttributes = new List<object>();
argumentAttributes = new List<List<object>>();
foreach (MethodInfo method in methodInfos)
{
// If we don't find an attribute, we'll set a null in the list at a token
methodAttributes.Add(null);
foreach (object att in method.GetCustomAttributes(false))
{
Type attType = att.GetType();
if (TypeHelper.TypeHasAncestorWithFullName(attType, "ExcelDna.Integration.ExcelFunctionAttribute") ||
TypeHelper.TypeHasAncestorWithFullName(attType, "ExcelDna.Integration.ExcelCommandAttribute"))
{
// Set last value to this attribute
methodAttributes[methodAttributes.Count - 1] = att;
break;
}
if (att is System.ComponentModel.DescriptionAttribute)
{
// Some compatibility - use Description if no Excel* attribute
if (methodAttributes[methodAttributes.Count - 1] == null)
methodAttributes[methodAttributes.Count - 1] = att;
}
}
List<object> argAttribs = new List<object>();
argumentAttributes.Add(argAttribs);
foreach (ParameterInfo param in method.GetParameters())
{
// If we don't find an attribute, we'll set a null in the list at a token
argAttribs.Add(null);
foreach (object att in param.GetCustomAttributes(false))
{
Type attType = att.GetType();
if (TypeHelper.TypeHasAncestorWithFullName(attType, "ExcelDna.Integration.ExcelArgumentAttribute"))
{
// Set last value to this attribute
argAttribs[argAttribs.Count - 1] = att;
break;
}
if (att is System.ComponentModel.DescriptionAttribute)
{
// Some compatibility - use Description if no ExcelArgument attribute
if (argAttribs[argAttribs.Count - 1] == null)
argAttribs[argAttribs.Count - 1] = att;
}
}
}
}
}