public IEntity GetDefaultMember() { IType defaultMemberAttribute = _typeSystemServices.Map(typeof(DefaultMemberAttribute)); foreach (Attribute attribute in _typeDefinition.Attributes) { IConstructor tag = TypeSystemServices.GetEntity(attribute) as IConstructor; if (null != tag) { if (defaultMemberAttribute == tag.DeclaringType) { StringLiteralExpression memberName = attribute.Arguments[0] as StringLiteralExpression; if (null != memberName) { List buffer = new List(); Resolve(buffer, memberName.Value, EntityType.Any); return(NameResolutionService.GetEntityFromList(buffer)); } } } } if (null != BaseType) { return(BaseType.GetDefaultMember()); } return(null); }
public IEntity GetDefaultMember() { IType defaultMemberAttribute = _typeSystemServices.Map(Types.DefaultMemberAttribute); foreach (Attribute attribute in _typeDefinition.Attributes) { IConstructor tag = TypeSystemServices.GetEntity(attribute) as IConstructor; if (null != tag) { if (defaultMemberAttribute == tag.DeclaringType) { StringLiteralExpression memberName = attribute.Arguments[0] as StringLiteralExpression; if (null != memberName) { List buffer = new List(); Resolve(buffer, memberName.Value, EntityType.Any); return(NameResolutionService.GetEntityFromList(buffer)); } } } } if (_typeDefinition.BaseTypes.Count > 0) { List buffer = new List(); foreach (TypeReference baseType in _typeDefinition.BaseTypes) { IType tag = TypeSystemServices.GetType(baseType); IEntity defaultMember = tag.GetDefaultMember(); if (defaultMember != null) { if (tag.IsInterface) { buffer.AddUnique(defaultMember); } else //non-interface base class trumps interfaces { return(defaultMember); } } } return(NameResolutionService.GetEntityFromList(buffer)); } return(null); }