public IAstAttribute CreateAstAttributeInstance()
{
object[] parameters = _attribute.Arguments.Count > 0 ? _attribute.Arguments.ToArray() : new object[0];
IAstAttribute aa = null;
try
{
aa = (IAstAttribute)Activator.CreateInstance(_type, parameters);
}
catch (MissingMethodException x)
{
_context.Errors.Add(CompilerErrorFactory.MissingConstructor(x, _attribute, _type, parameters));
return null;
}
aa.Attribute = _attribute;
if (_attribute.NamedArguments.Count > 0)
{
bool initialized = true;
foreach (ExpressionPair p in _attribute.NamedArguments)
{
bool success = SetFieldOrProperty(aa, p);
initialized = initialized && success;
}
if (!initialized)
{
return null;
}
}
return aa;
}