Thinktecture.Tools.Web.Services.CodeGeneration.AttributableCodeDomObject.FindAttribute C# (CSharp) Method

FindAttribute() public method

This method finds the attribute as specified by attribute parameter.
This method initially looks up an internal attribute cache. If the attribute is not found in the cache, it searches for it in the actual object extended by this instance. If the attribute is found, this method adds it to internal cache causing the faster access time in the subsequent requests.
public FindAttribute ( string attributeName ) : CodeAttributeDeclaration
attributeName string
return System.CodeDom.CodeAttributeDeclaration
        public CodeAttributeDeclaration FindAttribute(string attributeName)
        {
            if (string.IsNullOrEmpty(attributeName))
            {
                throw new ArgumentException("attributeName could not be null or an empty string.");
            }

            if (attributesCache.ContainsKey(attributeName))
            {
                return attributesCache[attributeName];
            }

            foreach (CodeAttributeDeclaration attribDecl in extendedObject.CustomAttributes)
            {
                if (attribDecl.Name == attributeName)
                {
                    attributesCache.Add(attributeName, attribDecl);
                    return attribDecl;
                }
            }
            return null;
        }