- www.gideondsouza.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IObservableHelper<T, TContext> | |
where T : class //or EntityObject | |
//where TContext : ObjectContext //optional | |
{ | |
IObservable<IList<T>> GetAllAsObservables(Func<TContext, IQueryable<T>> funcquery); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IUserRepository | |
{ | |
string GetUserName(int id);//one method for simplicity | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyUserRepo : IUserRepository | |
{ | |
string GetUserName(int id) | |
{ | |
//grab your username from your data base here. | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IUserRepository repo = new MyUserRepo();//this is bad!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RepoFactory | |
{ | |
public static IUserRepository UserRepo | |
{ | |
get {return MyUserRepo();} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IUserRepository rep = RepoFactory.UserRepo; |
OlderNewer