using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using System.IO; using System.Collections.Specialized; namespace Foo.DataAccessLayer { class ResourceHelper { // Used by DB to keep track of labels and Versioning public static StringDictionary s_VersioningTablesMap = new StringDictionary(); /// /// Get All Sql Table Resource Names /// /// public static string[] GetTableResourceNames() { List tableResources = new List(); string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); foreach (string ResourceName in resourceNames) { if(ResourceName.Contains("DataAccessLayer.Sql.Tables.")) tableResources.Add(ResourceName); } return tableResources.ToArray(); } /// /// Gives you just the Table Name without the Resource string before and after /// /// a table Resource name /// the table name public static string GetTableNameFromTableResourceName(string TableResouceName) { // First trim the sqlce TableResouceName = TableResouceName.Replace(".sqlce", ""); // Now find the last dot and trim from there int index = TableResouceName.LastIndexOf('.'); return TableResouceName.Substring(index + 1); } /// /// Get the Text/SQL String from a specified ResourceFileName /// /// a specific ResourceFileName /// public static string GetTextSqlFromResourceFile(string resourceFileName) { StreamReader stream = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceFileName)); if (stream != null) { string strText = stream.ReadToEnd(); strText = strText.Replace('\r', ' '); strText = strText.Replace('\n', ' '); return strText; } else return string.Empty; } } }