public class EmailSeprator
{
private string[] Parse(string idString)
{
string pattern = @"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" +
@"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" +
@"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";
return Regex.Split(idString.Trim(), pattern, RegexOptions.IgnoreCase);
}
public int Save(string Ids)
{
ArrayList mails=new ArrayList();
string[] listMails=Parse(Ids);
mails.AddRange(listMails);
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings.Get("ConnectionString"));
SqlDataAdapter sda = new SqlDataAdapter("Select Email from Testing", con);
DataSet DsSql = new DataSet();
sda.Fill(DsSql, "Emails");
for (int i = 0; i < listMails.Length; i++)
{
DataRow dr = DsSql.Tables["Emails"].NewRow();
dr["Email"] = mails[i].ToString();
DsSql.Tables["Emails"].Rows.Add(dr);
}
return sda.Update(DsSql);
}
}
Tuesday, April 28, 2009
Thursday, April 9, 2009
How to load dll dynamically at runtime & create instances.
public static T GetInstanceByCustomAttribute(Assembly assembly, string customAttributeName)
{
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
Object[] attributes = (Object[])type.GetCustomAttributes(false);
foreach (Object attribute in attributes)
{
//"LoggingFactoryImplementaionAttribute";
if (attribute.GetType().Name.ToLower().Equals(customAttributeName.ToLower()))
{
return (T)Activator.CreateInstance(type);
}
}
}
return default(T);
}
{
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
Object[] attributes = (Object[])type.GetCustomAttributes(false);
foreach (Object attribute in attributes)
{
//"LoggingFactoryImplementaionAttribute";
if (attribute.GetType().Name.ToLower().Equals(customAttributeName.ToLower()))
{
return (T)Activator.CreateInstance(type);
}
}
}
return default(T);
}
Subscribe to:
Posts (Atom)
