public static List <InnerSourceWithFunction <Point3D> > GetSourcesPlate(InnerSource <Point3D> source) { return(new List <InnerSourceWithFunction <Point3D> > { new InnerSourceWithFunction <Point3D>(source, InnerSourcePlate.SourceFunction) }); }
/// <summary> /// Initializes a new instance of the <see cref="ReadOnlyReactiveProperty{T}"/> class. /// </summary> /// <param name="source">The source.</param> /// <param name="initialValue">The initial value.</param> /// <param name="mode">The mode.</param> /// <param name="eventScheduler">The event scheduler.</param> /// <param name="equalityComparer">The equality comparer.</param> public ReadOnlyReactiveProperty( IObservable <T> source, T initialValue = default(T), ReactivePropertyMode mode = ReactivePropertyMode.DistinctUntilChanged | ReactivePropertyMode.RaiseLatestValueOnSubscribe, IScheduler eventScheduler = null, IEqualityComparer <T> equalityComparer = null) { LatestValue = initialValue; EqualityComparer = equalityComparer ?? EqualityComparer <T> .Default; var ox = mode.HasFlag(ReactivePropertyMode.DistinctUntilChanged) ? source.DistinctUntilChanged(EqualityComparer) : source; ox.Do(x => { LatestValue = x; InnerSource.OnNext(x); }) .ObserveOn(eventScheduler ?? ReactivePropertyScheduler.Default) .Subscribe(_ => { PropertyChanged?.Invoke(this, SingletonPropertyChangedEventArgs.Value); }) .AddTo(Subscription); IsRaiseLatestValueOnSubscribe = mode.HasFlag(ReactivePropertyMode.RaiseLatestValueOnSubscribe); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting /// unmanaged resources. /// </summary> public void Dispose() { if (!Subscription.IsDisposed) { InnerSource.OnCompleted(); Subscription.Dispose(); } }
public void Should_work() { var innerSource = new InnerSource(); var source = new Source { Value = innerSource }; innerSource.Parent = source; Mapper.Map <Destination>(source); }
public async Task FullyReadsEmptyStream(int bufferSize, int maxBytesWritten) { InnerSource.SetLength(0); var result = await Source.CopyToAsync(Destination, bufferSize, maxBytesWritten, CancellationToken.None); Assert.Empty(Destination.ToArray()); Assert.Equal(0, result.BytesWritten); Assert.Equal(0, Source.BytesRead); Assert.False(result.PartialRead); }
/// <summary> /// Notifies the provider that an observer is to receive notifications. /// </summary> /// <param name="observer">The object that is to receive notifications.</param> /// <returns> /// A reference to an interface that allows observers to stop receiving notifications before /// the provider has finished sending them. /// </returns> public IDisposable Subscribe(IObserver <T> observer) { if (Subscription.IsDisposed) { observer.OnCompleted(); return(Disposable.Empty); } var result = InnerSource.Subscribe(observer); if (IsRaiseLatestValueOnSubscribe) { observer.OnNext(LatestValue); } return(result); }
private void WriteInnerSource(StringBuilder sb, InnerSource innerSource) { if (innerSource.IsInnerTable) { var table = (InnerSource.InnerTable)innerSource; sb.Append(table.Item1.Schema.Name); } else if (innerSource.IsInnerSource) { sb.Append("("); var source = (InnerSource.InnerSource)innerSource; WriteQuery(sb, source.Item); sb.Append(")"); } else { throw new InvalidOperationException("Source has to be either a table or inner source"); } }
private static void WriteSourcedVariable(StringBuilder sb, InnerQuery query, InnerSource innerSource, Variable variable) { if (query.NamingProvider.TryGetSourceName(innerSource, out var innerSourceName)) { sb.Append(innerSourceName); sb.Append("."); if (innerSource.NamingProvider.TryGetVariableName(variable, out var variableName)) { sb.Append(variableName); } else { throw new InvalidOperationException("Cannot find name for a variable from source"); } } else { throw new InvalidOperationException("Cannot find name for an existing variable source"); } }
public static List <InnerSourceWithFunction <Point3D> > GetSourcesParalelepiped(InnerSource <Point3D> source) { return(new List <InnerSourceWithFunction <Point3D> > { new InnerSourceWithFunction <Point3D>( source, InnerSourceParallelepiped.SourceFunction) }); }
public InnerSourceWithFunction(InnerSource <T> bound, Func <T, double> function) { Bound = bound; Function = function; }