Permalink
Browse files

Remove obsolete #if's. Remove VariadicTemplates for WP7.

  • Loading branch information...
jlaanstra committed Apr 2, 2013
1 parent 8b94898 commit 713978be07f4a8c20ddba1a16c8557c081b74b76
@@ -45,22 +45,14 @@ public IDisposable SuppressChangeNotifications()
new ScheduledSubject<IObservedChange<object, object>>(RxApp.DeferredScheduler);
public IObservable<IObservedChange<object, object>> Changing {
-#if SILVERLIGHT
- get { return _Changing.Where(_ => _changeCountSuppressed == 0); }
-#else
get { return _Changing.Where(_ => Interlocked.Read(ref _changeCountSuppressed) == 0); }
-#endif
}
ISubject<IObservedChange<object, object>> _Changed =
new ScheduledSubject<IObservedChange<object, object>>(RxApp.DeferredScheduler);
public IObservable<IObservedChange<object, object>> Changed {
-#if SILVERLIGHT
- get { return _Changed.Where(_ => _changeCountSuppressed == 0); }
-#else
get { return _Changed.Where(_ => Interlocked.Read(ref _changeCountSuppressed) == 0); }
-#endif
}
}
}
@@ -203,11 +203,7 @@ internal class SemaphoreSubject<T> : ISubject<T>, IEnableLogger
public SemaphoreSubject(int maxCount, IScheduler sched = null)
{
this.Log().Debug("maxCount is '{0}'", maxCount);
-#if WP7
- _inner = new Subject<T>();
-#else
_inner = (sched != null ? (ISubject<T>)new ScheduledSubject<T>(sched) : new Subject<T>());
-#endif
_maxCount = maxCount;
}
@@ -63,9 +63,6 @@ public ReactiveCollection(IEnumerable<T> initialContents = null, IScheduler sche
}
[OnDeserialized]
-#if WP7
- public
-#endif
void setupRx(StreamingContext _) { setupRx(); }
void setupRx(IEnumerable<T> initialContents = null, IScheduler scheduler = null, double resetChangeThreshold = 0.3)
@@ -73,9 +73,6 @@ protected ReactiveObject()
}
[OnDeserialized]
-#if WP7
- public
-#endif
void setupRxObj(StreamingContext sc) { setupRxObj(); }
void setupRxObj()
@@ -168,14 +165,8 @@ void verifyPropertyName(string propertyName)
}
protected bool areChangeNotificationsEnabled {
- get {
-#if SILVERLIGHT
- // N.B. On most architectures, machine word aligned reads are
- // guaranteed to be atomic - sorry WP7, you're out of luck
- return changeNotificationsSuppressed == 0;
-#else
- return (Interlocked.Read(ref changeNotificationsSuppressed) == 0);
-#endif
+ get {
+ return (Interlocked.Read(ref changeNotificationsSuppressed) == 0);
}
}
@@ -60,10 +60,8 @@ public RoutingState()
}
[OnDeserialized]
-#if WP7
- public
-#endif
void setupRx(StreamingContext sc) { setupRx(); }
+
void setupRx()
{
if (rxObjectsSetup) return;
@@ -1,210 +0,0 @@
-
-using System;
-using System.Collections.Generic;
-using System.Reactive.Disposables;
-using System.Reactive.Linq;
-using System.Diagnostics.Contracts;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using System.Text;
-
-
-namespace ReactiveUI
-{
- public static class WhenAnyMixin
- {
-
- /// <summary>
- /// WhenAny allows you to observe whenever one or more properties on an
- /// object have changed, providing an initial value when the Observable
- /// is set up, unlike ObservableForProperty(). Use this method in
- /// constructors to set up bindings between properties that also need an
- /// initial setup.
- /// </summary>
- public static IObservable<TRet> WhenAny<TSender, TRet, T1>(this TSender This,
- Expression<Func<TSender, T1>> property1,
- Func<IObservedChange<TSender, T1>, TRet> selector)
- {
- return This.ObservableForProperty(property1, false, false).Select(selector);
- }
-
- /// <summary>
- /// WhenAny allows you to observe whenever one or more properties on an
- /// object have changed, providing an initial value when the Observable
- /// is set up, unlike ObservableForProperty(). Use this method in
- /// constructors to set up bindings between properties that also need an
- /// initial setup.
- /// </summary>
- public static IObservable<TRet> WhenAnyDynamic<TSender, TRet>(this TSender This,
- string[] property1,
- Func<IObservedChange<TSender, object>, TRet> selector)
- {
- return ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property1, false, false).Select(selector);
- }
-
-
- /// <summary>
- /// WhenAny allows you to observe whenever one or more properties on an
- /// object have changed, providing an initial value when the Observable
- /// is set up, unlike ObservableForProperty(). Use this method in
- /// constructors to set up bindings between properties that also need an
- /// initial setup.
- /// </summary>
- public static IObservable<TRet> WhenAny<TSender, TRet, T1,T2>(this TSender This,
- Expression<Func<TSender, T1>> property1,
- Expression<Func<TSender, T2>> property2,
- Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, TRet> selector)
- {
- return Observable.CombineLatest(
- This.ObservableForProperty(property1, false, false),
- This.ObservableForProperty(property2, false, false),
- selector
- );
- }
-
- /// <summary>
- /// WhenAny allows you to observe whenever one or more properties on an
- /// object have changed, providing an initial value when the Observable
- /// is set up, unlike ObservableForProperty(). Use this method in
- /// constructors to set up bindings between properties that also need an
- /// initial setup.
- /// </summary>
- public static IObservable<TRet> WhenAnyDynamic<TSender, TRet>(this TSender This,
- string[] property1,
- string[] property2,
- Func<IObservedChange<TSender, object>, IObservedChange<TSender, object>, TRet> selector)
- {
- return Observable.CombineLatest(
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property1, false, false),
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property2, false, false),
- selector
- );
- }
-
-
- /// <summary>
- /// WhenAny allows you to observe whenever one or more properties on an
- /// object have changed, providing an initial value when the Observable
- /// is set up, unlike ObservableForProperty(). Use this method in
- /// constructors to set up bindings between properties that also need an
- /// initial setup.
- /// </summary>
- public static IObservable<TRet> WhenAny<TSender, TRet, T1,T2,T3>(this TSender This,
- Expression<Func<TSender, T1>> property1,
- Expression<Func<TSender, T2>> property2,
- Expression<Func<TSender, T3>> property3,
- Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, TRet> selector)
- {
- return Observable.CombineLatest(
- This.ObservableForProperty(property1, false, false),
- This.ObservableForProperty(property2, false, false),
- This.ObservableForProperty(property3, false, false),
- selector
- );
- }
-
- /// <summary>
- /// WhenAny allows you to observe whenever one or more properties on an
- /// object have changed, providing an initial value when the Observable
- /// is set up, unlike ObservableForProperty(). Use this method in
- /// constructors to set up bindings between properties that also need an
- /// initial setup.
- /// </summary>
- public static IObservable<TRet> WhenAnyDynamic<TSender, TRet>(this TSender This,
- string[] property1,
- string[] property2,
- string[] property3,
- Func<IObservedChange<TSender, object>, IObservedChange<TSender, object>, IObservedChange<TSender, object>, TRet> selector)
- {
- return Observable.CombineLatest(
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property1, false, false),
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property2, false, false),
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property3, false, false),
- selector
- );
- }
-
-
- /// <summary>
- /// WhenAny allows you to observe whenever one or more properties on an
- /// object have changed, providing an initial value when the Observable
- /// is set up, unlike ObservableForProperty(). Use this method in
- /// constructors to set up bindings between properties that also need an
- /// initial setup.
- /// </summary>
- public static IObservable<TRet> WhenAny<TSender, TRet, T1,T2,T3,T4>(this TSender This,
- Expression<Func<TSender, T1>> property1,
- Expression<Func<TSender, T2>> property2,
- Expression<Func<TSender, T3>> property3,
- Expression<Func<TSender, T4>> property4,
- Func<IObservedChange<TSender, T1>, IObservedChange<TSender, T2>, IObservedChange<TSender, T3>, IObservedChange<TSender, T4>, TRet> selector)
- {
- return Observable.CombineLatest(
- This.ObservableForProperty(property1, false, false),
- This.ObservableForProperty(property2, false, false),
- This.ObservableForProperty(property3, false, false),
- This.ObservableForProperty(property4, false, false),
- selector
- );
- }
-
- /// <summary>
- /// WhenAny allows you to observe whenever one or more properties on an
- /// object have changed, providing an initial value when the Observable
- /// is set up, unlike ObservableForProperty(). Use this method in
- /// constructors to set up bindings between properties that also need an
- /// initial setup.
- /// </summary>
- public static IObservable<TRet> WhenAnyDynamic<TSender, TRet>(this TSender This,
- string[] property1,
- string[] property2,
- string[] property3,
- string[] property4,
- Func<IObservedChange<TSender, object>, IObservedChange<TSender, object>, IObservedChange<TSender, object>, IObservedChange<TSender, object>, TRet> selector)
- {
- return Observable.CombineLatest(
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property1, false, false),
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property2, false, false),
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property3, false, false),
- ReactiveNotifyPropertyChangedMixin
- .SubscribeToExpressionChain<TSender,object>(This, property4, false, false),
- selector
- );
- }
-
- }
-
- public static class WhenAnyObservableMixin
- {
- public static IObservable<TRet> WhenAnyObservable<TSender, TRet>(this TSender This, Expression<Func<TSender, IObservable<TRet>>> obs1)
- {
- return This.WhenAny(obs1, x => x.Value).Merge();
- }
-
- public static IObservable<TRet> WhenAnyObservable<TSender, TRet>(this TSender This, Expression<Func<TSender, IObservable<TRet>>> obs1, Expression<Func<TSender, IObservable<TRet>>> obs2)
- {
- return This.WhenAny(obs1, obs2, (o1, o2) => new[] {o1.Value, o2.Value})
- .SelectMany(x => x.Merge());
- }
- public static IObservable<TRet> WhenAnyObservable<TSender, TRet>(this TSender This, Expression<Func<TSender, IObservable<TRet>>> obs1, Expression<Func<TSender, IObservable<TRet>>> obs2, Expression<Func<TSender, IObservable<TRet>>> obs3)
- {
- return This.WhenAny(obs1, obs2, obs3, (o1, o2, o3) => new[] {o1.Value, o2.Value, o3.Value})
- .SelectMany(x => x.Merge());
- }
- public static IObservable<TRet> WhenAnyObservable<TSender, TRet>(this TSender This, Expression<Func<TSender, IObservable<TRet>>> obs1, Expression<Func<TSender, IObservable<TRet>>> obs2, Expression<Func<TSender, IObservable<TRet>>> obs3, Expression<Func<TSender, IObservable<TRet>>> obs4)
- {
- return This.WhenAny(obs1, obs2, obs3, obs4, (o1, o2, o3, o4) => new[] {o1.Value, o2.Value, o3.Value, o4.Value})
- .SelectMany(x => x.Merge());
- }
- }
-}
Oops, something went wrong.

0 comments on commit 713978b

Please sign in to comment.