AspNetEdit.Editor.ComponentModel.Document.GetFirstDirective C# (CSharp) 메소드

GetFirstDirective() 공개 메소드

Gets the first directive of a given type
public GetFirstDirective ( string directiveType, bool create ) : AspNetEdit.Editor.ComponentModel.DocumentDirective
directiveType string
create bool Whether the directive should be created if one does not already exist
리턴 AspNetEdit.Editor.ComponentModel.DocumentDirective
        public DocumentDirective GetFirstDirective(string directiveType, bool create)
        {
            foreach (DictionaryEntry de in directives)
            {
                if (de.Value is DocumentDirective)
                {
                    if (0 == string.Compare (((DocumentDirective)de.Value).Name, directiveType, true, CultureInfo.InvariantCulture))
                        return (DocumentDirective) de.Value ;
                }
                else
                    foreach (DocumentDirective d in (ArrayList)de.Value)
                        if (0 == string.Compare (d.Name, directiveType, true, CultureInfo.InvariantCulture))
                            return d;
            }

            //should directive be created if it can't be found?
            if (create) {
                AddDirective (directiveType, null);
                return GetFirstDirective (directiveType, false);
            }

            return null;
        }