Thursday, October 16, 2008

Using Resource files in Web Service (.NET 3.5) and Regular expression with LINQ

/*
Those who has tried to use resource file in ASP.NET web service know well there is issue in using resource files in web service. Following code snippet targets 3 points:
1. Using resource file in web service or HttpHandlers.
2. Regular expression for converting resource strings with respective localized strings
3. LINQ integration in Regular expression.
Suppose placeholder for resource string in text is like ({BR[MyResourceString]BR}) . Following function will return localized string.
*/


public static string LocalizedHTML(string inputHtml)
{
if (string.IsNullOrEmpty(inputHtml)) return "";

Regex reg = new Regex(@"\(\{IA\[(.*?)\]IA\}\)", RegexOptions.Multiline | RegexOptions.Singleline
| RegexOptions.IgnoreCase | RegexOptions.Compiled);


System.Resources.ResourceManager RM =
new System.Resources.ResourceManager("Resources.Language",
global::System.Reflection.Assembly.Load("App_GlobalResources"));


return reg.Replace(inputHtml, m => (!string.IsNullOrEmpty(RM.GetString(m.Groups[1].Value)) ? RM.GetString(m.Groups[1].Value) : m.Value));

}

Monday, October 13, 2008

Finding installed FTS IFilters on SQL 2005

Following command can be used to find out installed IFilters on SQL2005:

select * from sys.fulltext_document_types