Skip to content

Instantly share code, notes, and snippets.

View gideondsouza's full-sized avatar

Gideon Israel Dsouza gideondsouza

  • Dransfeld, Germany
View GitHub Profile
@gideondsouza
gideondsouza / ExportToCsvExtension.cs
Created December 2, 2011 11:46
An extension to export any IEnumerable<T> to CSV
using System.Text;
using System.Linq;
using System.Collections.Generic;
namespace Gideon.Extensions
{
static class ExportToCsvExtension
{
//awesomeness!! XD
//found this at http://mikehadlow.blogspot.com/2008/06/linq-to-csv.html tweaked and fixed it
public interface IObservableHelper<T, TContext>
where T : class //or EntityObject
//where TContext : ObjectContext //optional
{
IObservable<IList<T>> GetAllAsObservables(Func<TContext, IQueryable<T>> funcquery);
}
public class ObservableHelper<T> : IObservableHelper<T, Database1Entities>
where T : class //or EntityObject
{
public ObservableHelper()
{
_dat = new Database1Entities();
}
Database1Entities _dat;
public IObservable<IList<T>> GetAllAsObservables(Func<Database1Entities, IQueryable<T>> funcquery)
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
_repo = new ObservableHelper<Customer>();
ControlScheduler cs = new ControlScheduler(this);//WE NEED THIS.
Observable.FromEventPattern(h => textBox1.TextChanged += h,
h => textBox1.TextChanged -= h)//tell Rx about our event
@gideondsouza
gideondsouza / Form1.cs
Created December 2, 2011 11:53
Simple Rx Instance Search
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SearchList("");//load all
ControlScheduler cs = new ControlScheduler(this);//WE NEED THIS.
Observable.FromEventPattern(h => textBox1.TextChanged += h,
h => textBox1.TextChanged -= h)
interface IUserRepository
{
string GetUserName(int id);//one method for simplicity
}
class MyUserRepo : IUserRepository
{
string GetUserName(int id)
{
//grab your username from your data base here.
}
}
IUserRepository repo = new MyUserRepo();//this is bad!!
class RepoFactory
{
public static IUserRepository UserRepo
{
get {return MyUserRepo();}
}
}
IUserRepository rep = RepoFactory.UserRepo;