internal static unsafe bool FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, object[] attributes, IList derivedAttributes, out RuntimeType attributeType, out RuntimeMethodHandle ctor, out bool ctorHasParameters, out bool isVarArg)
{
ctor = new RuntimeMethodHandle();
attributeType = null;
ctorHasParameters = false;
isVarArg = false;
IntPtr ptr1 = (IntPtr) (((void*) caRecord.blob.Signature) + caRecord.blob.Length);
attributeType = decoratedModule.ResolveType(scope.GetParentToken((int) caRecord.tkCtor), null, null) as RuntimeType;
if (!attributeFilterType.IsAssignableFrom(attributeType))
{
return false;
}
if (!AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes))
{
return false;
}
if ((attributeType.Assembly != lastAptcaOkAssembly) && !attributeType.Assembly.AptcaCheck(decoratedModule.Assembly))
{
return false;
}
lastAptcaOkAssembly = decoratedModule.Assembly;
ConstArray methodSignature = scope.GetMethodSignature(caRecord.tkCtor);
isVarArg = (methodSignature[0] & 5) != 0;
ctorHasParameters = methodSignature[1] != 0;
if (ctorHasParameters)
{
ctor = decoratedModule.ModuleHandle.ResolveMethodHandle((int) caRecord.tkCtor);
}
else
{
ctor = attributeType.GetTypeHandleInternal().GetDefaultConstructor();
if (ctor.IsNullHandle() && !attributeType.IsValueType)
{
throw new MissingMethodException(".ctor");
}
}
if (ctor.IsNullHandle())
{
if (!attributeType.IsVisible && !attributeType.TypeHandle.IsVisibleFromModule(decoratedModule.ModuleHandle))
{
return false;
}
return true;
}
if (ctor.IsVisibleFromModule(decoratedModule))
{
return true;
}
MetadataToken token = new MetadataToken();
if (decoratedToken.IsParamDef)
{
token = new MetadataToken(scope.GetParentToken((int) decoratedToken));
token = new MetadataToken(scope.GetParentToken((int) token));
}
else if ((decoratedToken.IsMethodDef || decoratedToken.IsProperty) || (decoratedToken.IsEvent || decoratedToken.IsFieldDef))
{
token = new MetadataToken(scope.GetParentToken((int) decoratedToken));
}
else if (decoratedToken.IsTypeDef)
{
token = decoratedToken;
}
return (token.IsTypeDef && ctor.IsVisibleFromType(decoratedModule.ModuleHandle.ResolveTypeHandle((int) token)));
}