public static IDisposable BindToDirect <TTarget, TValue>(IObservable <TValue> This, TTarget target, Expression viewExpression) { var setter = global::ReactiveUI.Reflection.GetValueSetterOrThrow(viewExpression.GetMemberInfo()); if (viewExpression.GetParent().NodeType == ExpressionType.Parameter) { return(This.Subscribe( x => setter(target, x, viewExpression.GetArgumentsArray()), ex => { RxLog.Log(typeof(IViewForValidateableMixins), Classified.Error(ex)); //TODO:this.Log().ErrorException(String.Format("{0} Binding received an Exception!", viewExpression), ex); })); } var bindInfo = Observable.CombineLatest( This, target.WhenAnyDynamic(viewExpression.GetParent(), x => x.Value), (val, host) => new { val, host }); return(bindInfo .Where(x => x.host != null) .Subscribe( x => setter(x.host, x.val, viewExpression.GetArgumentsArray()), ex => { RxLog.Log(typeof(IViewForValidateableMixins), Classified.Error(ex)); //TODO:this.Log().ErrorException(String.Format("{0} Binding received an Exception!", viewExpression), ex); })); }
public static IObservable <TValue> BindToView <TView, TViewProp, TTarget, TValue>(IObservable <TValue> valueChange, TTarget target, Expression <Func <TView, TViewProp> > viewProperty) { var viewExpression = global::ReactiveUI.Reflection.Rewrite(viewProperty.Body); var setter = global::ReactiveUI.Reflection.GetValueSetterOrThrow(viewExpression.GetMemberInfo()); if (viewExpression.GetParent().NodeType == ExpressionType.Parameter) { return(valueChange.Do( x => setter(target, x, viewExpression.GetArgumentsArray()), ex => { RxLog.Log(typeof(ValidationBinding), Classified.Error(ex)); //todo: this.Log().ErrorException(String.Format("{0} Binding received an Exception!", viewExpression), ex); })); } var bindInfo = valueChange.CombineLatest(target.WhenAnyDynamic(viewExpression.GetParent(), x => x.Value), (val, host) => new { val, host }); return(bindInfo .Where(x => x.host != null) .Do( x => setter(x.host, x.val, viewExpression.GetArgumentsArray()), ex => { RxLog.Log(typeof(ValidationBinding), Classified.Error(ex)); //todo: this.Log().ErrorException(String.Format("{0} Binding received an Exception!", viewExpression), ex); }) .Select(v => v.val)); }
public ObservableMixinsTests() { _testSubject = new Subject <string>(); _mockLogHost = new Mock <IRxLogHost>(); _mockLogHost.Setup(p => p.Configuration).Returns(RxLoggerConfiguration.Create()); RxLog.SetDefault(new RxLog(_mockLogHost.Object)); }
public void Dispose() { _context.End(); // and log the timing block RxLog.Log(_meta, _context.TimingBlock); _context.Dispose(); }
public void StaticPublishChannelsThroughDefaultTest() { RxLog.SetDefault(_log); var entry = new RxLogEntry(new RxLogEntryMeta(null, "", 0), new object()); RxLog.Log(entry); _logHost.Verify(p => p.Publish(entry), Times.Once); }
/// <summary> /// Updates an existing <see cref="KeyedReactiveList{TItem,TKey}"/> smartly with a new set of items. /// </summary> /// <typeparam name="TItem"></typeparam> /// <typeparam name="TKey"></typeparam> /// <param name="destination"></param> /// <param name="source"></param> /// <remarks> /// Instead of a block replacement occuring, the <see cref="TKey"/> is used to determine /// items which have either been removed, moved or added and the destination list is updated in this once.</remarks> public static void SmartUpdate <TItem, TKey>(this KeyedReactiveList <TItem, TKey> destination, IReadOnlyList <TItem> source) { var index = 0; Guard.NotNull(destination); Guard.NotNull(source); try { // // construct the final set of keys var finalKeys = source.ToLookup(destination.KeyFor); // get the list of removals var removals = destination.Where(d => !finalKeys.Contains(destination.KeyFor(d))).ToList(); foreach (var removal in removals) { destination.Remove(removal); } // so now, we are just into additions and updates foreach (var newItem in source) { TItem currentItem; if (destination.GetForKey(destination.KeyFor(newItem), out currentItem)) { var currentIndex = destination.IndexOf(currentItem); if (currentIndex != index) { destination.Move(currentIndex, index); } else { destination[currentIndex] = newItem; } } else { destination.Insert(index, newItem); } ++index; } } catch (Exception ex) { // log the exception, and re-throw RxLog.Log(destination, Classified.Error(ex)); throw; } }
protected void pf_DrawImage() { if (_rct.IsEmpty) { return; } using (DrawingContext tdc = RenderOpen()) { RxLog.Trace(_rct.ToString()); //Brush tbrs1 = Brushes.Blue.Clone(); //tbrs1.Opacity = 0.25; //tdc.DrawRectangle(tbrs1, null, _rct); Brush tbrs2 = Brushes.Blue.Clone(); tbrs2.Opacity = 1.0; Pen tp1 = new Pen(tbrs2, 3); tdc.DrawRectangle(null, tp1, _rct); } }
public void SetDefaultTest() { RxLog.SetDefault(_log); Assert.Same(RxLog.Default, _log); }
public RxLogTests() { _logHost = new Moq.Mock <IRxLogHost>(); _log = new RxLog(_logHost.Object); }