This file contains 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
//This is the mutable version | |
class StudentSummaryMutable | |
{ | |
public int Id { get; private set; } | |
public string Name { get; private set; } | |
public IObservableCache<StudentWithClass, int> Classes { get; private set; } | |
public int[] Grades { get; private set; } |
This file contains 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
/// <summary> | |
/// Groups the source using the property specified by the property selector. Groups are re-applied when the property value changed. | |
/// | |
/// When there are likely to be a large number of property changes specify a throttle to improve performance | |
/// </summary> | |
/// <typeparam name="TObject">The type of the object.</typeparam> | |
/// <typeparam name="TKey">The type of the key.</typeparam> | |
/// <typeparam name="TGroupKey">The type of the group key.</typeparam> | |
/// <param name="source">The source.</param> | |
/// <param name="propertySelector">The property selector used to group the items</param> |
This file contains 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 JobInfoRepository : IDisposable | |
{ | |
private readonly IDisposable _cleanUp; | |
public IObservableCache<JobInfo, int> Results { get; } | |
public JobInfoRepository() | |
{ | |
var readWriteCache = new SourceCache<JobInfo, int>(ji => ji.JobID); | |
Results = readWriteCache.AsObservableCache(); |
This file contains 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 static class SqlObservations | |
{ | |
public static IObservable<IEnumerable<IDataRecord>> MonitorChanges(string connectionString, string sql) | |
{ | |
/* | |
1. read data from database and return results | |
2. monitor changes | |
3. when there is a change, repeat the whole process | |
*/ |
This file contains 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 static clas DynamicDataJoinEx | |
{ | |
/// <summary> | |
/// Joins the left and right observable data sources, combining the content into a single | |
/// </summary> | |
/// <typeparam name="TLeft">The object type of the left datasource</typeparam> | |
/// <typeparam name="TLeftKey">The key type of the left datasource</typeparam> | |
/// <typeparam name="TRight">The object type of the right datasource</typeparam> | |
/// <typeparam name="TRightKey">The key type of the right datasource</typeparam> | |
/// <typeparam name="TDestination">The resulting object which </typeparam> |
This file contains 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
/// <summary> | |
/// Transforms the without updates. Blah Blah | |
/// </summary> | |
/// <typeparam name="TObject">The type of the object.</typeparam> | |
/// <typeparam name="TKey">The type of the key.</typeparam> | |
/// <typeparam name="TDestination">The type of the destination.</typeparam> | |
/// <param name="source">The source.</param> | |
/// <param name="factory">The factory.</param> | |
/// <param name="updateAction">Apply changes to the original. Example (original, newitem) => original.Value = newitem.Value </param> | |
/// <returns></returns> |
This file contains 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 static IObservable<IChangeSet<WidgetListItemViewModel, int>> TransformWithupdate(this IObservable<IChangeSet<Widget, int>> source ) | |
{ | |
return Observable.Create<IChangeSet<WidgetListItemViewModel, int>>(observer => | |
{ | |
var shared = source | |
.Transform(w => new WidgetListItemViewModel(w)) | |
.Publish(); | |
//create cache which never replaces the original problem | |
var nonUpdatingObservableCache = shared |
This file contains 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 static class MyDynamicDataExtensions | |
{ | |
public static IObservable<IChangeSet<WidgetListItemViewModel, int>> TransformWithupdate(this IObservable<IChangeSet<Widget, int>> source ) | |
{ | |
return Observable.Create<IChangeSet<WidgetListItemViewModel, int>>(observer => | |
{ | |
//create local data source wich tansforms all items | |
var localDataSource = source | |
.Transform(w => new WidgetListItemViewModel(w)) | |
.AsObservableCache(); |
This file contains 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
namespace DynamicData.Samplz.Examples | |
{ | |
public class CombineUsingOrViewModel | |
{ | |
public CombineUsingOrViewModel() | |
{ | |
//maintain databaseDevices + databaseDevices anytime | |
var databaseDevices = new SourceCache<IDevice,int>(device => device.Id); | |
var localDevices = new SourceCache<IDevice, int>(device => device.Id); | |
This file contains 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 static class DynamicDataExtensions | |
{ | |
public static IObservable<IChangeSet<TObj, TKey>> FilterOnProperty<TObj, TKey, TProp>(this IObservable<IChangeSet<TObj, TKey>> source, | |
Expression<Func<TObj, TProp>> selectProp, | |
Func<TObj, bool> predicate) where TObj : INotifyPropertyChanged | |
{ | |
return Observable.Create<IChangeSet<TObj, TKey>>(observer => | |
{ | |
//share the connection, otherwise the entire observable chain is duplicated |