Boo.Lang.Compiler.TypeSystem.TypeSystemServices.GetEnumeratorItemTypeFromAttribute C# (CSharp) Method

GetEnumeratorItemTypeFromAttribute() private method

private GetEnumeratorItemTypeFromAttribute ( IType iteratorType ) : IType
iteratorType IType
return IType
        private IType GetEnumeratorItemTypeFromAttribute(IType iteratorType)
        {
            // If iterator type is external get its attributes via reflection
            if (iteratorType is ExternalType)
                return GetExternalEnumeratorItemType(iteratorType);

            // If iterator type is a generic constructed type, get its attribute from its definition
            // and map generic parameters
            if (iteratorType.ConstructedInfo != null)
            {
                IType definitionItemType = GetEnumeratorItemType(iteratorType.ConstructedInfo.GenericDefinition);
                return iteratorType.ConstructedInfo.Map(definitionItemType);
            }

            // If iterator type is internal get its attributes from its type definition
            var internalType = (AbstractInternalType) iteratorType;
            IType enumeratorItemTypeAttribute = Map(typeof(EnumeratorItemTypeAttribute));
            foreach (Ast.Attribute attribute in internalType.TypeDefinition.Attributes)
            {
                var constructor = GetEntity(attribute) as IConstructor;
                if (null != constructor && constructor.DeclaringType == enumeratorItemTypeAttribute)
                    return GetType(attribute.Arguments[0]);
            }
            return null;
        }
TypeSystemServices