/// <summary> /// Creates a mask to capsulate the source settable property. /// </summary> /// <typeparam name="TSource">The type of the property.</typeparam> /// <param name="source">The source property.</param> /// <returns>An <see cref="IGetOnlyProperty<TSource>"/> object.</returns> public static IGetOnlyProperty <TSource> ToGetOnlyMask <TSource>(this ISettableProperty <TSource> source) { if (source == null) { throw new ArgumentNullException("source"); } return(new GetOnlyPropertyMask <TSource>(source)); }
public GetOnlyPropertyMask(ISettableProperty <T> source) { if (source == null) { throw new ArgumentNullException("source"); } _source = source; }
public static IGetOnlyProperty <TResult> SelectToGetOnly <TSource, TResult>(this ISettableProperty <TSource> source, Func <TSource, TResult> selector, bool notifiesUnchanged) { if (source == null) { throw new ArgumentNullException("source"); } if (selector == null) { throw new ArgumentNullException("selector"); } return(new FollowingGetOnlyProperty <TResult>(source.Select(selector), selector(source.Value), notifiesUnchanged)); }
public AsyncKinectManager() { _Sensor = ObservableProperty.CreateSettable <KinectSensor>(null); Sensor = _Sensor.ToGetOnlyMask(); SensorDisconnected = _Sensor .Select(s => _sensorCache) .Where(s => s != null) .ToGetOnly(null, true); SensorConnected = _Sensor .Do(s => _sensorCache = s) .Where(s => s != null) .ToGetOnly(null, true); }
public AppModel() { Position = ObservableProperty.CreateSettable(new Point()); var client = EventHubClient.Create("sakapon-event-201508"); var index = 0; Position .Select(p => new { index = index++, position = p.ToString() }) .Select(o => JsonConvert.SerializeObject(o)) .Do(m => Debug.WriteLine("Sending message. {0}", new[] { m })) .Select(m => new EventData(Encoding.UTF8.GetBytes(m))) .Subscribe(d => client.SendAsync(d)); }
public AppModel() { var timer = Observable.Interval(TimeSpan.FromSeconds(1)).Select(_ => DateTime.Now); var random = new Random(); FirstName = ObservableProperty.CreateSettable("Jiro"); LastName = ObservableProperty.CreateSettable("Mita"); FullName = ObservableProperty.CreateGetOnly(() => string.Format("{0} {1}", FirstName.Value, LastName.Value)); FirstName.Merge(LastName).Subscribe(FullName); Message = FirstName.SelectToGetOnly(name => string.Format("Hello, {0}!", name)); CurrentTime = timer.ToGetOnly(DateTime.Now); // 初期値をランダムに設定する場合。 //RandomNumber = CurrentTime.SelectToGetOnly(_ => random.Next(0, 3), true); RandomNumber = timer.Select(_ => random.Next(0, 3)).ToGetOnly(0, true); _Count = ObservableProperty.CreateSettable(0); Count = _Count.ToGetOnlyMask(); RandomNumber.Subscribe(_ => _Count.Value++); }
static StaticEventProcessor() { Message = ObservableProperty.CreateSettable <string>(null); }
/// <summary> /// Creates an instance of IObservable-based get-only property from the predecessor settable property. /// </summary> /// <typeparam name="TSource">The type of the source property.</typeparam> /// <typeparam name="TResult">The type of the property.</typeparam> /// <param name="source">The source property.</param> /// <param name="selector">The transform function.</param> /// <returns>An <see cref="IGetOnlyProperty<TResult>"/> object.</returns> public static IGetOnlyProperty <TResult> SelectToGetOnly <TSource, TResult>(this ISettableProperty <TSource> source, Func <TSource, TResult> selector) { return(SelectToGetOnly(source, selector, false)); }