Exemplo n.º 1
0
        /// <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&lt;TSource&gt;"/> object.</returns>
        public static IGetOnlyProperty <TSource> ToGetOnlyMask <TSource>(this ISettableProperty <TSource> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(new GetOnlyPropertyMask <TSource>(source));
        }
Exemplo n.º 2
0
        public GetOnlyPropertyMask(ISettableProperty <T> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            _source = source;
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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++);
        }
Exemplo n.º 7
0
 static StaticEventProcessor()
 {
     Message = ObservableProperty.CreateSettable <string>(null);
 }
Exemplo n.º 8
0
 /// <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&lt;TResult&gt;"/> object.</returns>
 public static IGetOnlyProperty <TResult> SelectToGetOnly <TSource, TResult>(this ISettableProperty <TSource> source, Func <TSource, TResult> selector)
 {
     return(SelectToGetOnly(source, selector, false));
 }