// Copyright (c) 2007 Omer Rauchwerger (a.k.a rauchy) (omer@rauchy.net) // All rights reserved. // // This file is part of Regionerate. // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; using System.Diagnostics; using System.Reflection; using System.Xml; namespace BestBrains.System { public static class CommentReader { #region Fields (2)  private static StackFrame callingMethodFrame; private static readonly XmlDocument generatedDocumentation = new XmlDocument(); #endregion Fields  #region Methods (1)  // Public Methods (1)  public static string GetElement( string elementName ) { StackTrace stackTrace = new StackTrace(); callingMethodFrame = stackTrace.GetFrame( 1 ); generatedDocumentation.Load( String.Format( "{0}.xml", Assembly.GetCallingAssembly().FullName.Split( ',' )[ 0 ] ) ); XmlNode node = generatedDocumentation.SelectSingleNode( String.Format( "doc/members/member[contains(@name, '{0}.{1}')]/{2}", callingMethodFrame.GetMethod().DeclaringType, callingMethodFrame.GetMethod().Name, elementName ) ); if ( node != null ) { return node.InnerXml; } else { throw new ArgumentException( String.Format( "Element '{0}' not found.", elementName ) ); } } #endregion Methods  } }