initial oogynize check in _ this actually used to work!
This commit is contained in:
68
DataAccessLayer/ResourceHelper.cs
Normal file
68
DataAccessLayer/ResourceHelper.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
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();
|
||||
|
||||
/// <summary>
|
||||
/// Get All Sql Table Resource Names
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string[] GetTableResourceNames()
|
||||
{
|
||||
List<String> tableResources = new List<string>();
|
||||
|
||||
string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
|
||||
foreach (string ResourceName in resourceNames)
|
||||
{
|
||||
if(ResourceName.Contains("DataAccessLayer.Sql.Tables."))
|
||||
tableResources.Add(ResourceName);
|
||||
}
|
||||
|
||||
return tableResources.ToArray<String>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gives you just the Table Name without the Resource string before and after
|
||||
/// </summary>
|
||||
/// <param name="TableResouceName">a table Resource name</param>
|
||||
/// <returns>the table name</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Text/SQL String from a specified ResourceFileName
|
||||
/// </summary>
|
||||
/// <param name="resourceFileName">a specific ResourceFileName</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user